Difference between pages "r7.1.1:Define LIBTEST PAL STDLIB CALLBACK CALLING CONVENTION" and "r7.1.1:Define LIBTEST PAL STORE CONDITIONAL"

From liblfds.org
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
{{DISPLAYTITLE:define LIBTEST_PAL_STDLIB_CALLBACK_CALLING_CONVENTION}}
{{DISPLAYTITLE:macro LIBTEST_PAL_STORE_CONDITIONAL}}
==Source File==
==Source File==
  └───test_and_benchmark
  └───test_and_benchmark
Line 7: Line 7:
                     libtest_porting_abstraction_layer_compiler.h
                     libtest_porting_abstraction_layer_compiler.h


==Define==
==Macro==
  #define LIBTEST_PAL_STDLIB_CALLBACK_CALLING_CONVENTION  [calling convention]
  #define LIBTEST_PAL_STORE_CONDITIONAL( destination, source, stored_flag )
 
==Parameters==
''destination''
: A ''lfds711_pal_uint_t *'', which must be the ''source'' argument of the previous call to ''LIBTEST_PAL_LOAD_LINKED''.
 
''source''
: A ''lfds711_pal_uint_t'', to be written into ''*destination''.
 
''stored_flag''
: A ''lfds711_pal_uint_t'', which is set to 0 on success, 1 on failure.
 
==Return Value==
No return value.


==Example==
==Example==
  #if( defined _WIN32 && define KERNEL_BUILD && defined _M_IX86 )
  #define LIBTEST_PAL_STORE_CONDITIONAL( destination, source, stored_flag )   \
   
  {                                                                            \
   // TRD : bloody x86 on MSVC...
   __asm__ __volatile__                                                      \
   #define LIBTEST_PAL_STDLIB_CALLBACK_CALLING_CONVENTION __cdecl
   (                                                                          \
    "strex %[alias_sf], %[alias_src], [%[alias_dst]];"                      \
  #endif
    : "=m" (*destination),                                                  \
      [alias_sf] "=&r" (stored_flag)                                        \
    : [alias_src] "r" (source),                                              \
      [alias_dst] "r" (destination)                                          \
  );                                                                        \
  }


==Optionality==
==Optionality==
This define is mandatory and the library cannot compile if in the cases where it is needed, it is not set.  If the define is not required, it must be defined as empty, rather than omitted.
This macro is optional.  If not provided, it must be absent, rather than defined empty.  If this macro and ''LIBTEST_PAL_LOAD_LINKED'' are implemented, the function [[r7.1.1:function libtest_misc_determine_erg|libtest_misc_determine_erg]] can be used.


==Notes==
==Notes==
Winner of "World's Most Annoying Abstraction Define" award.
This macro implements the store-conditional half of a load-linked/store-conditional pairThe value pointed to by ''source'' is conditionally-stored into desintation.
 
When building for and only for Windows kernel targetting x86, callback functions passed to standard library functions such as ''qsort'' or ''bsearch'' have a calling convention which differs to the build default, which breaks compilationThis has to be handled, and that in turns means this define has to exist.  It is defined as empty on all platforms except for Windows kernel x86.
 
This define will go away when the vestigal use of ''qsort'' and ''bsearch'' (there's one use of each) are removed from ''libtest''.


==See Also==
==See Also==
* [[r7.1.1:Porting Guide (libtest)|Porting Guide (libtest)]]
* [[r7.1.1:Porting Guide (libtest)|Porting Guide (libtest)]]

Latest revision as of 20:16, 17 February 2017

Source File

└───test_and_benchmark
    └───libtest
        └───inc
            └───libtest
                    libtest_porting_abstraction_layer_compiler.h

Macro

#define LIBTEST_PAL_STORE_CONDITIONAL( destination, source, stored_flag )

Parameters

destination

A lfds711_pal_uint_t *, which must be the source argument of the previous call to LIBTEST_PAL_LOAD_LINKED.

source

A lfds711_pal_uint_t, to be written into *destination.

stored_flag

A lfds711_pal_uint_t, which is set to 0 on success, 1 on failure.

Return Value

No return value.

Example

#define LIBTEST_PAL_STORE_CONDITIONAL( destination, source, stored_flag )    \
{                                                                            \
  __asm__ __volatile__                                                       \
  (                                                                          \
    "strex  %[alias_sf], %[alias_src], [%[alias_dst]];"                      \
    : "=m" (*destination),                                                   \
      [alias_sf] "=&r" (stored_flag)                                         \
    : [alias_src] "r" (source),                                              \
      [alias_dst] "r" (destination)                                          \
  );                                                                         \
}

Optionality

This macro is optional. If not provided, it must be absent, rather than defined empty. If this macro and LIBTEST_PAL_LOAD_LINKED are implemented, the function libtest_misc_determine_erg can be used.

Notes

This macro implements the store-conditional half of a load-linked/store-conditional pair. The value pointed to by source is conditionally-stored into desintation.

See Also