X11workbench Toolkit  1.0

Macros

#define INVALID_HANDLE_VALUE
 INVALID HANDLE VALUE equivalent. More...
 
#define HAS_WB_UINT64_BUILTIN
 defined whenever the 'WB_UINT64' data type is a 'built in' data type
 
#define WB_C99_INITIALIZERS   /* allow C99-style initializers */
 Defined in 'platform_helper.h' when the compiler supports C99 initializers.
 
#define __PACKED__   /* platform dependent; actual def must be a blank or doxygen barphs on it */
 PACKED definition. More...
 
#define DECLARE_SORT_FUNCTION(fn_name, p0, p1, p2)   int fn_name(void *p0, const void *p1, const void *p2)
 Wrapper to declare a sort function for QSORT_R. More...
 
#define QSORT_R(base, nmemb, size, thunk, compar)   my_qsort_r((base),(nmemb),(size),(thunk),(compar))
 Local implementation of qsort_r() for operating systems that do not have it. More...
 
#define WB_STRINGIZE(X)   WB_STRINGIZE_INTERNAL(X)
 stringize a macro argument More...
 
#define WB_STRINGIZE_INTERNAL(X)   #X
 helper to stringize a macro argument
 
#define WB_UNLIKELY(x)   (__builtin_expect (!!(x), 0))
 optimization for code branching when condition is 'unlikely'. use within conditionals More...
 
#define WB_LIKELY(x)   (__builtin_expect (!!(x), 1))
 optimization for code branching when condition is 'likely'. use within conditionals More...
 
#define WB_UNUSED   __attribute__((unused))
 marks a variable as likely to be 'unused'. warning abatement. Place macro directly after the variable name More...
 
#define WB_INTERNAL_ATOM_MIN_VAL   0x3f000000L
 The minimum 'internal' Atom value used by the toolkit. More...
 
#define WB_SECURE_HASH_TIMEOUT   60000
 

Detailed Description

Macro Definition Documentation

◆ __PACKED__

#define __PACKED__   /* platform dependent; actual def must be a blank or doxygen barphs on it */

PACKED definition.

This assignes the 'packed' attribute; i.e. byte-level alignment. Not valid for Microsoft's compilers

Definition at line 521 of file platform_helper.h.

◆ DECLARE_SORT_FUNCTION

#define DECLARE_SORT_FUNCTION (   fn_name,
  p0,
  p1,
  p2 
)    int fn_name(void *p0, const void *p1, const void *p2)

Wrapper to declare a sort function for QSORT_R.

Parameters
fn_nameThe function name
p0The 'thunk' parameter passed in by QSORT_R
p1The first compare parameter
p2The second compare parameter

Use this wrapper macro to properly declare a compare function for QSORT_R, similar to the following example:

DECLARE_SORT_FUNCTION(MySort,pThunk,pParam1,pParam2)
{
const char **pStringArray = (const char **)pThunk; // the real data
const int *pP1 = (const int *)pParam1;
const int *pP2 = (const int *)pParam2;
// I am sorting integer indices into an array of character strings so
// that I can sort the integers and not the actual strings. But I needed
// a pointer to my string array, so I pass that in as 'pThunk'.
return strcmp(pStringArray[*pP1],pStringArray[*pP2]);
}

this helps resolve the known platform differences in qsort_r() for POSIX systems

See also
QSORT_R

Definition at line 1356 of file platform_helper.h.

◆ INVALID_HANDLE_VALUE

#define INVALID_HANDLE_VALUE

INVALID HANDLE VALUE equivalent.

This definition generically refers to an INVALID HANDLE, more specifically a FILE or SOCKET handle on POSIX systems

Definition at line 293 of file platform_helper.h.

◆ QSORT_R

#define QSORT_R (   base,
  nmemb,
  size,
  thunk,
  compar 
)    my_qsort_r((base),(nmemb),(size),(thunk),(compar))

Local implementation of qsort_r() for operating systems that do not have it.

Parameters
basePointer to 'base' of items to sort
nmembNumber of members to sort
sizeSize of a single member (including any padding)
thunkThe value to pass along as the first parameter to 'compar'
comparThe comparison function, declared using DECLARE_SORT_FUNCTION

Use this UNIVERSALLY whenever you need to use qsort_r(), as it is platform independent and deals with the incompatibilities associated with the BSD version and the Linux version, as well as implementing qsort_r() for systems that do not support it directly.

Definition at line 1372 of file platform_helper.h.

◆ WB_INTERNAL_ATOM_MIN_VAL

#define WB_INTERNAL_ATOM_MIN_VAL   0x3f000000L

The minimum 'internal' Atom value used by the toolkit.

This is the minimum 'internal' Atom value that is used by the toolkit. Atoms that are allocated via XInternAtom() will have a value that is LESS than WB_INTERNAL_ATOM_MIN_VAL, and anything allocated via WBGetAtom() will have a value that is GREATER THAN OR EQUAL to WB_INTERNAL_ATOM_MIN_VAL.

Use of this constant to determine 'internal' from 'X11' Atoms is based on the source code for the Xorg X11 server, which uses the function 'MakeAtom()' (in 'dix/atom.c') to allocate new atoms. These values are assigned SEQUENTIALLY, beginning with 'XA_LAST_PREDEFINED+1' and continuing from there. A value of this magnitude allows for about 1 billion Atom allocations before 'hitting the limit'. (having that many atoms would negatively impact the X windows system)

In the future, it is possible that an Atom MAY have a randomly assigned value, or a value assigned that clashes with this definition. In such a case, a major re-write might be needed to correct for it.

NOTE: This value must NOT include any of the bits 'Or'd with an Atom within a menu, such as 'WBMENU_POPUP_HIGH_BIT' or 'WBMENU_DYNAMIC_HIGH_BIT'. Otherwise, THAT architecture would need to be modified as well.the minimum 'internal' Atom value used by the toolkit

Definition at line 391 of file platform_helper.h.

◆ WB_LIKELY

#define WB_LIKELY (   x)    (__builtin_expect (!!(x), 1))

optimization for code branching when condition is 'likely'. use within conditionals

if(WB_LIKELY(x == 5))
{
// branch optimized to execute this code when condition is TRUE
}

Definition at line 342 of file platform_helper.h.

◆ WB_SECURE_HASH_TIMEOUT

#define WB_SECURE_HASH_TIMEOUT   60000

'secure hash' maximum lifetime, in milliseconds

Definition at line 590 of file platform_helper.h.

◆ WB_STRINGIZE

#define WB_STRINGIZE (   X)    WB_STRINGIZE_INTERNAL(X)

stringize a macro argument

Parameters
XA macro argument that you want substituted with a stringized version

Use this to 'stringize' a parameter passed to a macro.

Definition at line 308 of file platform_helper.h.

◆ WB_UNLIKELY

#define WB_UNLIKELY (   x)    (__builtin_expect (!!(x), 0))

optimization for code branching when condition is 'unlikely'. use within conditionals

if(WB_UNLIKELY(x == 5))
{
// branch optimized to bypass this code when condition is FALSE
}

Definition at line 332 of file platform_helper.h.

◆ WB_UNUSED

#define WB_UNUSED   __attribute__((unused))

marks a variable as likely to be 'unused'. warning abatement. Place macro directly after the variable name

int an_unused_var WB_UNUSED = 5; // no compiler warnings if I don't actually use this variable

NOTE: may also be used for function parameters. In some cases a callback function may have unused
parameters passed to it. Marking them with 'WB_UNUSED' helps prevent unnecessary compiler warnings.

Definition at line 364 of file platform_helper.h.