Difference between pages "r7.1.1:Define LIBSHARED PAL THREAD RETURN TYPE" and "r7.1.1:Define LIBTEST PAL LOAD LINKED"

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 LIBSHARED_PAL_THREAD_RETURN_TYPE}}
{{DISPLAYTITLE:macro LIBTEST_PAL_LOAD_LINKED}}
==Source File==
==Source File==
  └───test_and_benchmark
  └───test_and_benchmark
     └───libshared
     └───libtest
         └───inc
         └───inc
             └───libshared
             └───libtest
                     libshared_porting_abstraction_layer_compiler.h
                     libtest_porting_abstraction_layer_compiler.h


==Define==
==Macro==
  #define LIBSHARED_PAL_THREAD_RETURN_TYPE  libshared_pal_thread_return_t
  #define LIBTEST_PAL_LOAD_LINKED( destination, source )
   
 
or
==Parameters==
''destination''
#define LIBSHARED_PAL_THREAD_RETURN_TYPE  int
: A ''lfds711_pal_uint_t'', which is set to the value of ''*source''.
 
''source''
: A ''lfds711_pal_uint_t *''. The value pointed to by this argument is copied into ''destination''.
 
==Return Value==
No return value.


==Example==
==Example==
  #define LIBSHARED_PAL_THREAD_RETURN_TYPE libshared_pal_thread_return_t
  #define LIBTEST_PAL_LOAD_LINKED( destination, source ) \
{                                                      \
  __asm__ __volatile__                                  \
  (                                                    \
    "ldrex  %[alias_dst], [%[alias_src]];"              \
    : [alias_dst] "=r" (destination)                    \
    : [alias_src] "r" (source)                          \
  );                                                    \
}


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


==Notes==
==Notes==
Windows kernel mode threads are unique in that the thread function returns ''void''.  As such, two problems are presented; firstly, the existing code, which is cross-platform and so has thread functions which return a variable, often attempts to declare on the stack a variable of the type ''libshared_pal_thread_return_t'', which is set to a value during the course of operation and then returnedHowever, if ''libshared_pal_thread_return_t'' is ''void'', then the compiler throws an error, because it is not possible to declare variables of type ''void''.  Secondly, the return from the thread function must be empty - where all the existing threads are returning a value or variable.
This macro implements the load-linked half of a load-linked/store-conditional pairThe value pointed to by ''source'' is link-loaded into desintation.
 
To solve this, one define (this define) and one macro (''[[r7.1.1:macro LIBSHARED_PAL_THREAD_RETURN_CAST|LIBSHARED_PAL_THREAD_RETURN_CAST]]'') are provided.  This define provides for Windows kernel a harmless type which will permit the thread function code to compile.  The macro ''LIBSHARED_PAL_THREAD_RETURN_CAST'' wraps the return argument and on Windows kernel, consumes it - makes it disappear - by being an empty macro.  On other platforms, the macro itself disappears, leaving just its argument, which then gives us what we want in both cases.


==See Also==
==See Also==
* [[r7.1.1:Porting Guide (libshared)|Porting Guide (libshared)]]
* [[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_LOAD_LINKED( destination, source )

Parameters

destination

A lfds711_pal_uint_t, which is set to the value of *source.

source

A lfds711_pal_uint_t *. The value pointed to by this argument is copied into destination.

Return Value

No return value.

Example

#define LIBTEST_PAL_LOAD_LINKED( destination, source )  \
{                                                       \
  __asm__ __volatile__                                  \
  (                                                     \
    "ldrex  %[alias_dst], [%[alias_src]];"              \
    : [alias_dst] "=r" (destination)                    \
    : [alias_src] "r" (source)                          \
  );                                                    \
}

Optionality

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

Notes

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

See Also