1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SAL_RTL_STRIMP_HXX
21 #define INCLUDED_SAL_RTL_STRIMP_HXX
23 #include <config_probes.h>
28 #include <sal/types.h>
29 #include <rtl/string.h>
30 #include <rtl/ustring.h>
32 /* ======================================================================= */
33 /* Help functions for String and UString */
34 /* ======================================================================= */
37 * refCount is opaque and includes 2 bit-fields;
38 * MSB: 'interned' - is stored in the intern hash
39 * MSB-1: 'static' - is a const / static string,
42 #define SAL_STRING_INTERN_FLAG 0x80000000
43 #define SAL_STRING_STATIC_FLAG 0x40000000
44 #define SAL_STRING_REFCOUNT(a) ((a) & 0x3fffffff)
46 #define SAL_STRING_IS_INTERN(a) ((a)->refCount & SAL_STRING_INTERN_FLAG)
47 #define SAL_STRING_IS_STATIC(a) ((a)->refCount & SAL_STRING_STATIC_FLAG)
49 rtl_uString
* rtl_uString_ImplAlloc( sal_Int32 nLen
);
51 rtl_String
* rtl_string_ImplAlloc( sal_Int32 nLen
);
55 typedef void *(SAL_CALL
* rtl_allocateStringFn
)(size_t size
);
56 typedef void (*rtl_freeStringFn
)(void *);
60 extern rtl_allocateStringFn rtl_allocateString
;
61 extern rtl_freeStringFn rtl_freeString
;
63 // string lifetime instrumentation / diagnostics
65 # define PROBE_SNAME(n,b) n ## _ ## b
66 # define PROBE_NAME(n,b) PROBE_SNAME(n,b)
67 # define PROBE_NEW PROBE_NAME (new_string,RTL_LOG_STRING_BITS)
68 # define PROBE_DEL PROBE_NAME (delete_string,RTL_LOG_STRING_BITS)
69 # define PROBE_INTERN_NEW PROBE_NAME (new_string_intern,RTL_LOG_STRING_BITS)
70 # define PROBE_INTERN_DEL PROBE_NAME (delete_string_intern,RTL_LOG_STRING_BITS)
71 # define RTL_LOG_STRING_NEW(s) \
72 DTRACE_PROBE4(libreoffice, PROBE_NEW, s, \
73 (s)->refCount, (s)->length, (s)->buffer)
74 # define RTL_LOG_STRING_DELETE(s) \
75 DTRACE_PROBE4(libreoffice, PROBE_DEL, s, \
76 (s)->refCount, (s)->length, (s)->buffer)
77 # define RTL_LOG_STRING_INTERN_NEW(s,o) \
78 DTRACE_PROBE5(libreoffice, PROBE_INTERN_NEW, s, \
79 (s)->refCount, (s)->length, (s)->buffer, o)
80 # define RTL_LOG_STRING_INTERN_DELETE(s) \
81 DTRACE_PROBE4(libreoffice, PROBE_INTERN_DEL, s, \
82 (s)->refCount, (s)->length, (s)->buffer)
84 # define RTL_LOG_STRING_NEW(s)
85 # define RTL_LOG_STRING_DELETE(s)
86 # define RTL_LOG_STRING_INTERN_NEW(s,o)
87 # define RTL_LOG_STRING_INTERN_DELETE(s)
88 #endif /* USE_SDT_PROBES */
90 #endif // INCLUDED_SAL_RTL_STRIMP_HXX
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */