From bb47bd5159992c970f0e9c054de709a80dd43f64 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 23 Oct 2023 19:16:42 +0200 Subject: [PATCH] make style --- firmware/application/src/app_config.h | 2 +- .../application/src/rfid/reader/hf/rc522.c | 32 +- firmware/application/src/utils/fds_util.c | 10 +- software/script/chameleon_cli_unit.py | 33 +- software/script/chameleon_enum.py | 3 +- software/src/lib/pthread/include/pthread.h | 600 +++++++++--------- software/src/lib/pthread/include/sched.h | 38 +- software/src/lib/pthread/include/semaphore.h | 64 +- software/src/nested_util.c | 37 +- 9 files changed, 404 insertions(+), 415 deletions(-) diff --git a/firmware/application/src/app_config.h b/firmware/application/src/app_config.h index 5dc7023..2d4d247 100644 --- a/firmware/application/src/app_config.h +++ b/firmware/application/src/app_config.h @@ -5,7 +5,7 @@ //#define APP_FW_VER_MAJOR 2 //#define APP_FW_VER_MINOR 0 #if !(defined APP_FW_VER_MAJOR && defined APP_FW_VER_MINOR) - #error You need to define APP_FW_VER_MAJOR and APP_FW_VER_MINOR +#error You need to define APP_FW_VER_MAJOR and APP_FW_VER_MINOR #endif // Merge major and minor version code to U16 value. diff --git a/firmware/application/src/rfid/reader/hf/rc522.c b/firmware/application/src/rfid/reader/hf/rc522.c index 6cf7e7a..7fc615f 100644 --- a/firmware/application/src/rfid/reader/hf/rc522.c +++ b/firmware/application/src/rfid/reader/hf/rc522.c @@ -487,18 +487,18 @@ uint8_t pcd_14a_reader_bits_transfer(uint8_t *pTx, uint16_t szTxBits, uint8_t * * @param :tag: tag info buffer * @retval : if return STATUS_HF_TAG_OK, the tag is selected. */ -uint8_t pcd_14a_reader_fast_select(picc_14a_tag_t *tag) { - uint8_t resp[5] = {0}; // theoretically. A usual RATS will be much smaller - uint8_t uid_resp[4] = {0}; +uint8_t pcd_14a_reader_fast_select(picc_14a_tag_t *tag) { + uint8_t resp[5] = {0}; // theoretically. A usual RATS will be much smaller + uint8_t uid_resp[4] = {0}; uint8_t sak = 0x04; // cascade uid - uint8_t status = STATUS_HF_TAG_OK; - uint8_t cascade_level = 0; - uint16_t len; - - // Wakeup + uint8_t status = STATUS_HF_TAG_OK; + uint8_t cascade_level = 0; + uint16_t len; + + // Wakeup if (pcd_14a_reader_atqa_request(resp, NULL, U8ARR_BIT_LEN(resp)) != STATUS_HF_TAG_OK) { - return STATUS_HF_TAG_NO; - } + return STATUS_HF_TAG_NO; + } // OK we will select at least at cascade 1, lets see if first byte of UID was 0x88 in // which case we need to make a cascade 2 request and select - this is a long UID @@ -520,14 +520,14 @@ uint8_t pcd_14a_reader_fast_select(picc_14a_tag_t *tag) { //sel_uid[1] = 0x70; // transmitting a full UID (1 Byte cmd, 1 Byte NVB, 4 Byte UID, 1 Byte BCC, 2 Bytes CRC) memcpy(sel_uid + 2, uid_resp, 4); // the UID received during anticollision, or the provided UID sel_uid[6] = sel_uid[2] ^ sel_uid[3] ^ sel_uid[4] ^ sel_uid[5]; // calculate and add BCC - crc_14a_append(sel_uid, 7); // calculate and add CRC - status = pcd_14a_reader_bytes_transfer(PCD_TRANSCEIVE, sel_uid, sizeof(sel_uid), resp, &len, U8ARR_BIT_LEN(resp)); + crc_14a_append(sel_uid, 7); // calculate and add CRC + status = pcd_14a_reader_bytes_transfer(PCD_TRANSCEIVE, sel_uid, sizeof(sel_uid), resp, &len, U8ARR_BIT_LEN(resp)); // Receive the SAK if (status != STATUS_HF_TAG_OK || !len) { - // printf("SAK Err: %d, %d\r\n", status, recv_len); - return STATUS_HF_TAG_NO; - } - + // printf("SAK Err: %d, %d\r\n", status, recv_len); + return STATUS_HF_TAG_NO; + } + sak = resp[0]; // Test if more parts of the uid are coming diff --git a/firmware/application/src/utils/fds_util.c b/firmware/application/src/utils/fds_util.c index 46407ea..109ddb7 100644 --- a/firmware/application/src/utils/fds_util.c +++ b/firmware/application/src/utils/fds_util.c @@ -194,11 +194,11 @@ static bool is_peer_manager_record(uint16_t id_or_key) { static void fds_evt_handler(fds_evt_t const *p_evt) { // Skip peermanager event if (fds_operation_info.ignore_pm && ( - is_peer_manager_record(p_evt->write.record_key) - || is_peer_manager_record(p_evt->write.file_id) - || is_peer_manager_record(p_evt->del.record_key) - || is_peer_manager_record(p_evt->del.file_id) - ) + is_peer_manager_record(p_evt->write.record_key) + || is_peer_manager_record(p_evt->write.file_id) + || is_peer_manager_record(p_evt->del.record_key) + || is_peer_manager_record(p_evt->del.file_id) + ) ) { return; } diff --git a/software/script/chameleon_cli_unit.py b/software/script/chameleon_cli_unit.py index 31a0f58..0fd5d0e 100644 --- a/software/script/chameleon_cli_unit.py +++ b/software/script/chameleon_cli_unit.py @@ -388,6 +388,7 @@ lf = root.subgroup('lf', 'Low Frequency commands') lf_em = lf.subgroup('em', 'EM commands') lf_em_410x = lf_em.subgroup('410x', 'EM410x commands') + @root.command('clear') class RootClear(BaseCLIUnit): def args_parser(self) -> ArgumentParserNoExit: @@ -1124,11 +1125,11 @@ class HFMFEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequiredU fwslot = SlotNumber.to_fw(self.slot_num) hf_tag_type = TagSpecificType(slotinfo[fwslot]['hf']) if hf_tag_type not in [ - TagSpecificType.MIFARE_Mini, - TagSpecificType.MIFARE_1024, - TagSpecificType.MIFARE_2048, - TagSpecificType.MIFARE_4096, - ]: + TagSpecificType.MIFARE_Mini, + TagSpecificType.MIFARE_1024, + TagSpecificType.MIFARE_2048, + TagSpecificType.MIFARE_4096, + ]: print(f"{CR}Slot {self.slot_num} not configured as MIFARE Classic{C0}") return mfc_config = self.cmd.mf1_get_emulator_config() @@ -1310,7 +1311,7 @@ class HFMFUDUMP(MFUAuthArgsUnit): } for i in range(param.start_page, param.stop_page): resp = self.cmd.hf14a_raw(options=options, resp_timeout_ms=200, data=struct.pack('!BB', 0x30, i)) - # TODO: can be optimized as we get 4 pages at once but beware of wrapping + # TODO: can be optimized as we get 4 pages at once but beware of wrapping # in case of end of memory or LOCK on ULC and no key provided data = resp[:4] print(f" - Page {i:2}: {data.hex()}") @@ -1347,10 +1348,10 @@ class HFMFUEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequired fwslot = SlotNumber.to_fw(self.slot_num) hf_tag_type = TagSpecificType(slotinfo[fwslot]['hf']) if hf_tag_type not in [ - TagSpecificType.NTAG_213, - TagSpecificType.NTAG_215, - TagSpecificType.NTAG_216, - ]: + TagSpecificType.NTAG_213, + TagSpecificType.NTAG_215, + TagSpecificType.NTAG_216, + ]: print(f"{CR}Slot {self.slot_num} not configured as MIFARE Ultralight / NTAG{C0}") return change_requested, change_done, uid, atqa, sak, ats = self.update_hf14a_anticoll(args, uid, atqa, sak, ats) @@ -1462,11 +1463,11 @@ class HWSlotList(DeviceRequiredUnit): if len(ats) > 0: print(f' {"ATS:":40}{CY}{ats.hex().upper()}{C0}') if hf_tag_type in [ - TagSpecificType.MIFARE_Mini, - TagSpecificType.MIFARE_1024, - TagSpecificType.MIFARE_2048, - TagSpecificType.MIFARE_4096, - ]: + TagSpecificType.MIFARE_Mini, + TagSpecificType.MIFARE_1024, + TagSpecificType.MIFARE_2048, + TagSpecificType.MIFARE_4096, + ]: config = self.cmd.mf1_get_emulator_config() # print(' - Mifare Classic emulator settings:') print( @@ -1480,7 +1481,7 @@ class HWSlotList(DeviceRequiredUnit): f'{f"{CG}enabled{C0}" if config["block_anti_coll_mode"] else f"{CR}disabled{C0}"}') try: print(f' {"Write mode:":40}{CY}' - f'{MifareClassicWriteMode(config["write_mode"])}{C0}') + f'{MifareClassicWriteMode(config["write_mode"])}{C0}') except ValueError: print(f' {"Write mode:":40}{CR}invalid value!{C0}') print( diff --git a/software/script/chameleon_enum.py b/software/script/chameleon_enum.py index 7bac615..274ae76 100644 --- a/software/script/chameleon_enum.py +++ b/software/script/chameleon_enum.py @@ -1,5 +1,6 @@ import enum + @enum.unique class Command(enum.IntEnum): GET_APP_VERSION = 1000 @@ -430,5 +431,3 @@ class ButtonPressFunction(enum.IntEnum): elif self == ButtonPressFunction.BATTERY: return "Show Battery Level" return "None" - - diff --git a/software/src/lib/pthread/include/pthread.h b/software/src/lib/pthread/include/pthread.h index b4072f7..2f3e988 100644 --- a/software/src/lib/pthread/include/pthread.h +++ b/software/src/lib/pthread/include/pthread.h @@ -5,25 +5,25 @@ * Pthreads-win32 - POSIX Threads Library for Win32 * Copyright(C) 1998 John E. Bossom * Copyright(C) 1999,2005 Pthreads-win32 contributors - * + * * Contact Email: rpj@callisto.canberra.edu.au - * + * * The current list of contributors is contained * in the file CONTRIBUTORS included with the source * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., @@ -231,8 +231,8 @@ typedef unsigned long ULONG_PTR; * Boolean values to make us independent of system includes. */ enum { - PTW32_FALSE = 0, - PTW32_TRUE = (! PTW32_FALSE) + PTW32_FALSE = 0, + PTW32_TRUE = (! PTW32_FALSE) }; /* @@ -318,8 +318,8 @@ enum { #if !defined(_TIMESPEC_DEFINED) #define _TIMESPEC_DEFINED struct timespec { - time_t tv_sec; - long tv_nsec; + time_t tv_sec; + long tv_nsec; }; #endif /* _TIMESPEC_DEFINED */ #endif /* HAVE_STRUCT_TIMESPEC */ @@ -519,14 +519,14 @@ extern "C" #undef _POSIX_THREAD_THREADS_MAX #define _POSIX_THREAD_THREADS_MAX 64 - /* Arbitrary value */ +/* Arbitrary value */ #undef PTHREAD_THREADS_MAX #define PTHREAD_THREADS_MAX 2019 #undef _POSIX_SEM_NSEMS_MAX #define _POSIX_SEM_NSEMS_MAX 256 - /* Arbitrary value */ +/* Arbitrary value */ #undef SEM_NSEMS_MAX #define SEM_NSEMS_MAX 1024 @@ -578,24 +578,24 @@ extern "C" * IA-32 or IA-64. */ typedef struct { - void * p; /* Pointer to actual object */ + void *p; /* Pointer to actual object */ unsigned int x; /* Extra information - reuse count etc */ } ptw32_handle_t; typedef ptw32_handle_t pthread_t; -typedef struct pthread_attr_t_ * pthread_attr_t; +typedef struct pthread_attr_t_ *pthread_attr_t; typedef struct pthread_once_t_ pthread_once_t; -typedef struct pthread_key_t_ * pthread_key_t; -typedef struct pthread_mutex_t_ * pthread_mutex_t; -typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; -typedef struct pthread_cond_t_ * pthread_cond_t; -typedef struct pthread_condattr_t_ * pthread_condattr_t; +typedef struct pthread_key_t_ *pthread_key_t; +typedef struct pthread_mutex_t_ *pthread_mutex_t; +typedef struct pthread_mutexattr_t_ *pthread_mutexattr_t; +typedef struct pthread_cond_t_ *pthread_cond_t; +typedef struct pthread_condattr_t_ *pthread_condattr_t; #endif -typedef struct pthread_rwlock_t_ * pthread_rwlock_t; -typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; -typedef struct pthread_spinlock_t_ * pthread_spinlock_t; -typedef struct pthread_barrier_t_ * pthread_barrier_t; -typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; +typedef struct pthread_rwlock_t_ *pthread_rwlock_t; +typedef struct pthread_rwlockattr_t_ *pthread_rwlockattr_t; +typedef struct pthread_spinlock_t_ *pthread_spinlock_t; +typedef struct pthread_barrier_t_ *pthread_barrier_t; +typedef struct pthread_barrierattr_t_ *pthread_barrierattr_t; /* * ==================== @@ -606,53 +606,53 @@ typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; */ enum { -/* - * pthread_attr_{get,set}detachstate - */ - PTHREAD_CREATE_JOINABLE = 0, /* Default */ - PTHREAD_CREATE_DETACHED = 1, + /* + * pthread_attr_{get,set}detachstate + */ + PTHREAD_CREATE_JOINABLE = 0, /* Default */ + PTHREAD_CREATE_DETACHED = 1, -/* - * pthread_attr_{get,set}inheritsched - */ - PTHREAD_INHERIT_SCHED = 0, - PTHREAD_EXPLICIT_SCHED = 1, /* Default */ + /* + * pthread_attr_{get,set}inheritsched + */ + PTHREAD_INHERIT_SCHED = 0, + PTHREAD_EXPLICIT_SCHED = 1, /* Default */ -/* - * pthread_{get,set}scope - */ - PTHREAD_SCOPE_PROCESS = 0, - PTHREAD_SCOPE_SYSTEM = 1, /* Default */ + /* + * pthread_{get,set}scope + */ + PTHREAD_SCOPE_PROCESS = 0, + PTHREAD_SCOPE_SYSTEM = 1, /* Default */ -/* - * pthread_setcancelstate paramters - */ - PTHREAD_CANCEL_ENABLE = 0, /* Default */ - PTHREAD_CANCEL_DISABLE = 1, + /* + * pthread_setcancelstate paramters + */ + PTHREAD_CANCEL_ENABLE = 0, /* Default */ + PTHREAD_CANCEL_DISABLE = 1, -/* - * pthread_setcanceltype parameters - */ - PTHREAD_CANCEL_ASYNCHRONOUS = 0, - PTHREAD_CANCEL_DEFERRED = 1, /* Default */ + /* + * pthread_setcanceltype parameters + */ + PTHREAD_CANCEL_ASYNCHRONOUS = 0, + PTHREAD_CANCEL_DEFERRED = 1, /* Default */ -/* - * pthread_mutexattr_{get,set}pshared - * pthread_condattr_{get,set}pshared - */ - PTHREAD_PROCESS_PRIVATE = 0, - PTHREAD_PROCESS_SHARED = 1, + /* + * pthread_mutexattr_{get,set}pshared + * pthread_condattr_{get,set}pshared + */ + PTHREAD_PROCESS_PRIVATE = 0, + PTHREAD_PROCESS_SHARED = 1, -/* - * pthread_mutexattr_{get,set}robust - */ - PTHREAD_MUTEX_STALLED = 0, /* Default */ - PTHREAD_MUTEX_ROBUST = 1, + /* + * pthread_mutexattr_{get,set}robust + */ + PTHREAD_MUTEX_STALLED = 0, /* Default */ + PTHREAD_MUTEX_ROBUST = 1, -/* - * pthread_barrier_wait - */ - PTHREAD_BARRIER_SERIAL_THREAD = -1 + /* + * pthread_barrier_wait + */ + PTHREAD_BARRIER_SERIAL_THREAD = -1 }; /* @@ -674,12 +674,11 @@ enum { */ #define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} -struct pthread_once_t_ -{ - int done; /* indicates if user function has been executed */ - void * lock; - int reserved1; - int reserved2; +struct pthread_once_t_ { + int done; /* indicates if user function has been executed */ + void *lock; + int reserved1; + int reserved2; }; @@ -710,19 +709,18 @@ struct pthread_once_t_ /* * Mutex types. */ -enum -{ - /* Compatibility with LinuxThreads */ - PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, - /* For compatibility with POSIX */ - PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +enum { + /* Compatibility with LinuxThreads */ + PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, + /* For compatibility with POSIX */ + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL }; @@ -739,17 +737,16 @@ typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); #pragma warning( default : 4229 ) #endif -struct ptw32_cleanup_t -{ - ptw32_cleanup_callback_t routine; - void *arg; - struct ptw32_cleanup_t *prev; +struct ptw32_cleanup_t { + ptw32_cleanup_callback_t routine; + void *arg; + struct ptw32_cleanup_t *prev; }; #if defined(__CLEANUP_SEH) - /* - * WIN32 SEH version of cancel cleanup. - */ +/* + * WIN32 SEH version of cancel cleanup. + */ #define pthread_cleanup_push( _rout, _arg ) \ { \ @@ -775,9 +772,9 @@ struct ptw32_cleanup_t #if defined(__CLEANUP_C) - /* - * C implementation of PThreads cancel cleanup - */ +/* + * C implementation of PThreads cancel cleanup + */ #define pthread_cleanup_push( _rout, _arg ) \ { \ @@ -793,71 +790,68 @@ struct ptw32_cleanup_t #if defined(__CLEANUP_CXX) +/* + * C++ version of cancel cleanup. + * - John E. Bossom. + */ + +class PThreadCleanup { + /* + * PThreadCleanup + * + * Purpose + * This class is a C++ helper class that is + * used to implement pthread_cleanup_push/ + * pthread_cleanup_pop. + * The destructor of this class automatically + * pops the pushed cleanup routine regardless + * of how the code exits the scope + * (i.e. such as by an exception) + */ + ptw32_cleanup_callback_t cleanUpRout; + void *obj; + int executeIt; + + public: + PThreadCleanup() : + cleanUpRout(0), + obj(0), + executeIt(0) /* - * C++ version of cancel cleanup. - * - John E. Bossom. + * No cleanup performed */ + { + } - class PThreadCleanup { - /* - * PThreadCleanup - * - * Purpose - * This class is a C++ helper class that is - * used to implement pthread_cleanup_push/ - * pthread_cleanup_pop. - * The destructor of this class automatically - * pops the pushed cleanup routine regardless - * of how the code exits the scope - * (i.e. such as by an exception) - */ - ptw32_cleanup_callback_t cleanUpRout; - void * obj; - int executeIt; - - public: - PThreadCleanup() : - cleanUpRout( 0 ), - obj( 0 ), - executeIt( 0 ) - /* - * No cleanup performed - */ - { - } - - PThreadCleanup( - ptw32_cleanup_callback_t routine, - void * arg ) : - cleanUpRout( routine ), - obj( arg ), - executeIt( 1 ) - /* - * Registers a cleanup routine for 'arg' - */ - { - } - - ~PThreadCleanup() - { - if ( executeIt && ((void *) cleanUpRout != (void *) 0) ) - { - (void) (*cleanUpRout)( obj ); - } - } - - void execute( int exec ) - { - executeIt = exec; - } - }; - + PThreadCleanup( + ptw32_cleanup_callback_t routine, + void *arg) : + cleanUpRout(routine), + obj(arg), + executeIt(1) /* - * C++ implementation of PThreads cancel cleanup; - * This implementation takes advantage of a helper - * class who's destructor automatically calls the - * cleanup routine if we exit our scope weirdly + * Registers a cleanup routine for 'arg' */ + { + } + + ~PThreadCleanup() { + if (executeIt && ((void *) cleanUpRout != (void *) 0)) { + (void)(*cleanUpRout)(obj); + } + } + + void execute(int exec) { + executeIt = exec; + } +}; + +/* + * C++ implementation of PThreads cancel cleanup; + * This implementation takes advantage of a helper + * class who's destructor automatically calls the + * cleanup routine if we exit our scope weirdly + */ #define pthread_cleanup_push( _rout, _arg ) \ { \ PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ @@ -888,240 +882,240 @@ struct ptw32_cleanup_t /* * PThread Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_init(pthread_attr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy(pthread_attr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, - int *detachstate); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate(const pthread_attr_t *attr, + int *detachstate); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, - void **stackaddr); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr(const pthread_attr_t *attr, + void **stackaddr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, - size_t * stacksize); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize(const pthread_attr_t *attr, + size_t *stacksize); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, - int detachstate); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate(pthread_attr_t *attr, + int detachstate); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, - void *stackaddr); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr(pthread_attr_t *attr, + void *stackaddr); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, - size_t stacksize); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize(pthread_attr_t *attr, + size_t stacksize); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, - struct sched_param *param); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam(const pthread_attr_t *attr, + struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, - const struct sched_param *param); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam(pthread_attr_t *attr, + const struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, - int); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy(pthread_attr_t *, + int); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, - int *); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy(const pthread_attr_t *, + int *); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, - int inheritsched); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t *attr, + int inheritsched); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, - int * inheritsched); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t *attr, + int *inheritsched); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, - int); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope(pthread_attr_t *, + int); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, - int *); +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope(const pthread_attr_t *, + int *); /* * PThread Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, - const pthread_attr_t * attr, - void *(PTW32_CDECL *start) (void *), - void *arg); +PTW32_DLLPORT int PTW32_CDECL pthread_create(pthread_t *tid, + const pthread_attr_t *attr, + void *(PTW32_CDECL *start)(void *), + void *arg); -PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); +PTW32_DLLPORT int PTW32_CDECL pthread_detach(pthread_t tid); -PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, - pthread_t t2); +PTW32_DLLPORT int PTW32_CDECL pthread_equal(pthread_t t1, + pthread_t t2); -PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); +PTW32_DLLPORT void PTW32_CDECL pthread_exit(void *value_ptr); -PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, - void **value_ptr); +PTW32_DLLPORT int PTW32_CDECL pthread_join(pthread_t thread, + void **value_ptr); -PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); +PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self(void); -PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); +PTW32_DLLPORT int PTW32_CDECL pthread_cancel(pthread_t thread); -PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, - int *oldstate); +PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate(int state, + int *oldstate); -PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, - int *oldtype); +PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype(int type, + int *oldtype); -PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); +PTW32_DLLPORT void PTW32_CDECL pthread_testcancel(void); -PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, - void (PTW32_CDECL *init_routine) (void)); +PTW32_DLLPORT int PTW32_CDECL pthread_once(pthread_once_t *once_control, + void (PTW32_CDECL *init_routine)(void)); #if PTW32_LEVEL >= PTW32_LEVEL_MAX -PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); +PTW32_DLLPORT ptw32_cleanup_t *PTW32_CDECL ptw32_pop_cleanup(int execute); -PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - ptw32_cleanup_callback_t routine, - void *arg); +PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup(ptw32_cleanup_t *cleanup, + ptw32_cleanup_callback_t routine, + void *arg); #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ /* * Thread Specific Data Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, - void (PTW32_CDECL *destructor) (void *)); +PTW32_DLLPORT int PTW32_CDECL pthread_key_create(pthread_key_t *key, + void (PTW32_CDECL *destructor)(void *)); -PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); +PTW32_DLLPORT int PTW32_CDECL pthread_key_delete(pthread_key_t key); -PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, - const void *value); +PTW32_DLLPORT int PTW32_CDECL pthread_setspecific(pthread_key_t key, + const void *value); -PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); +PTW32_DLLPORT void *PTW32_CDECL pthread_getspecific(pthread_key_t key); /* * Mutex Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init(pthread_mutexattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy(pthread_mutexattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t - * attr, - int *pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared(const pthread_mutexattr_t + * attr, + int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, - int pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, + int pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind); PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setrobust( - pthread_mutexattr_t *attr, - int robust); + pthread_mutexattr_t *attr, + int robust); PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust( - const pthread_mutexattr_t * attr, - int * robust); + const pthread_mutexattr_t *attr, + int *robust); /* * Barrier Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init(pthread_barrierattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy(pthread_barrierattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t - * attr, - int *pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared(const pthread_barrierattr_t + * attr, + int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, - int pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, + int pshared); /* * Mutex Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, - const pthread_mutexattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy(pthread_mutex_t *mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock(pthread_mutex_t *mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, - const struct timespec *abstime); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t *mutex, + const struct timespec *abstime); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock(pthread_mutex_t *mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock(pthread_mutex_t *mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex); +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent(pthread_mutex_t *mutex); /* * Spinlock Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_spin_init(pthread_spinlock_t *lock, int pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); +PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy(pthread_spinlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); +PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock(pthread_spinlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); +PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock(pthread_spinlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); +PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock(pthread_spinlock_t *lock); /* * Barrier Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, - const pthread_barrierattr_t * attr, - unsigned int count); +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init(pthread_barrier_t *barrier, + const pthread_barrierattr_t *attr, + unsigned int count); -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy(pthread_barrier_t *barrier); -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait(pthread_barrier_t *barrier); /* * Condition Variable Attribute Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init(pthread_condattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy(pthread_condattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, - int *pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared(const pthread_condattr_t *attr, + int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, - int pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared(pthread_condattr_t *attr, + int pshared); /* * Condition Variable Functions */ -PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, - const pthread_condattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_cond_init(pthread_cond_t *cond, + const pthread_condattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); +PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy(pthread_cond_t *cond); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, - pthread_mutex_t * mutex); +PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait(pthread_cond_t *cond, + pthread_mutex_t *mutex); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime); +PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait(pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *abstime); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); +PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal(pthread_cond_t *cond); -PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); +PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast(pthread_cond_t *cond); /* * Scheduling */ -PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, - int policy, - const struct sched_param *param); +PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam(pthread_t thread, + int policy, + const struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, - int *policy, - struct sched_param *param); +PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam(pthread_t thread, + int *policy, + struct sched_param *param); -PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); - -PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); +PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency(int); + +PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency(void); /* * Read-Write Lock Functions */ PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, - const pthread_rwlockattr_t *attr); + const pthread_rwlockattr_t *attr); PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); @@ -1132,24 +1126,24 @@ PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, - const struct timespec *abstime); + const struct timespec *abstime); PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, - const struct timespec *abstime); + const struct timespec *abstime); PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init(pthread_rwlockattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, - int *pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, + int *pshared); -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, - int pshared); +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, + int pshared); #if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 @@ -1166,15 +1160,15 @@ PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); /* * Compatibility with Linux. */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, - int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, - int *kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, + int kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t *attr, + int *kind); /* * Possibly supported by other POSIX threads implementations */ -PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); +PTW32_DLLPORT int PTW32_CDECL pthread_delay_np(struct timespec *interval); PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread); @@ -1192,8 +1186,8 @@ PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); */ PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int); enum ptw32_features { - PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ - PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ + PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ + PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ }; /* @@ -1204,7 +1198,7 @@ enum ptw32_features { * WM_TIMECHANGE message. It can be passed directly to * pthread_create() as a new thread if desired. */ -PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); +PTW32_DLLPORT void *PTW32_CDECL pthread_timechange_handler_np(void *); #endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ @@ -1217,7 +1211,7 @@ PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread) /* * Returns the win32 thread ID for POSIX thread. */ -PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); +PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np(pthread_t thread); /* @@ -1235,9 +1229,9 @@ PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); * argument to TimedWait is simply passed to * WaitForMultipleObjects. */ -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, - DWORD timeout); +PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait(HANDLE waitHandle); +PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait(HANDLE waitHandle, + DWORD timeout); #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ @@ -1246,11 +1240,11 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, */ #if !defined(_UWIN) # if defined(NEED_ERRNO) - PTW32_DLLPORT int * PTW32_CDECL _errno( void ); +PTW32_DLLPORT int *PTW32_CDECL _errno(void); # else # if !defined(errno) # if (defined(_MT) || defined(_DLL)) - __declspec(dllimport) extern int * __cdecl _errno(void); +__declspec(dllimport) extern int *__cdecl _errno(void); # define errno (*_errno()) # endif # endif @@ -1307,10 +1301,10 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); * propagate our internal exceptions up to the library's internal handlers. */ #if defined(_MSC_VER) - /* - * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' - * if you want Pthread-Win32 cancelation and pthread_exit to work. - */ +/* + * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' + * if you want Pthread-Win32 cancelation and pthread_exit to work. + */ #if !defined(PtW32NoCatchWarn) diff --git a/software/src/lib/pthread/include/sched.h b/software/src/lib/pthread/include/sched.h index f36a97a..05cf793 100644 --- a/software/src/lib/pthread/include/sched.h +++ b/software/src/lib/pthread/include/sched.h @@ -3,7 +3,7 @@ * * Purpose: * Provides an implementation of POSIX realtime extensions - * as defined in + * as defined in * * POSIX 1003.1b-1993 (POSIX.1b) * @@ -12,25 +12,25 @@ * Pthreads-win32 - POSIX Threads Library for Win32 * Copyright(C) 1998 John E. Bossom * Copyright(C) 1999,2005 Pthreads-win32 contributors - * + * * Contact Email: rpj@callisto.canberra.edu.au - * + * * The current list of contributors is contained * in the file CONTRIBUTORS included with the source * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., @@ -123,24 +123,24 @@ /* Required by Unix 98 */ # include # else - typedef int pid_t; +typedef int pid_t; # endif #else - typedef int pid_t; +typedef int pid_t; #endif /* Thread scheduling policies */ enum { - SCHED_OTHER = 0, - SCHED_FIFO, - SCHED_RR, - SCHED_MIN = SCHED_OTHER, - SCHED_MAX = SCHED_RR + SCHED_OTHER = 0, + SCHED_FIFO, + SCHED_RR, + SCHED_MIN = SCHED_OTHER, + SCHED_MAX = SCHED_RR }; struct sched_param { - int sched_priority; + int sched_priority; }; #if defined(__cplusplus) @@ -148,15 +148,15 @@ extern "C" { #endif /* __cplusplus */ -PTW32_DLLPORT int __cdecl sched_yield (void); +PTW32_DLLPORT int __cdecl sched_yield(void); -PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); +PTW32_DLLPORT int __cdecl sched_get_priority_min(int policy); -PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); +PTW32_DLLPORT int __cdecl sched_get_priority_max(int policy); -PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); +PTW32_DLLPORT int __cdecl sched_setscheduler(pid_t pid, int policy); -PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); +PTW32_DLLPORT int __cdecl sched_getscheduler(pid_t pid); /* * Note that this macro returns ENOTSUP rather than diff --git a/software/src/lib/pthread/include/semaphore.h b/software/src/lib/pthread/include/semaphore.h index c6e9407..5704d0e 100644 --- a/software/src/lib/pthread/include/semaphore.h +++ b/software/src/lib/pthread/include/semaphore.h @@ -2,35 +2,35 @@ * Module: semaphore.h * * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: + * Semaphores aren't actually part of the PThreads standard. + * They are defined by the POSIX Standard: * - * POSIX 1003.1b-1993 (POSIX.1b) + * POSIX 1003.1b-1993 (POSIX.1b) * * -------------------------------------------------------------------------- * * Pthreads-win32 - POSIX Threads Library for Win32 * Copyright(C) 1998 John E. Bossom * Copyright(C) 1999,2005 Pthreads-win32 contributors - * + * * Contact Email: rpj@callisto.canberra.edu.au - * + * * The current list of contributors is contained * in the file CONTRIBUTORS included with the source * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., @@ -120,50 +120,50 @@ #if defined(__cplusplus) extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ #if !defined(HAVE_MODE_T) typedef unsigned int mode_t; #endif -typedef struct sem_t_ * sem_t; +typedef struct sem_t_ *sem_t; -PTW32_DLLPORT int __cdecl sem_init (sem_t * sem, - int pshared, - unsigned int value); +PTW32_DLLPORT int __cdecl sem_init(sem_t *sem, + int pshared, + unsigned int value); -PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem); +PTW32_DLLPORT int __cdecl sem_destroy(sem_t *sem); -PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem); +PTW32_DLLPORT int __cdecl sem_trywait(sem_t *sem); -PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem); +PTW32_DLLPORT int __cdecl sem_wait(sem_t *sem); -PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem, - const struct timespec * abstime); +PTW32_DLLPORT int __cdecl sem_timedwait(sem_t *sem, + const struct timespec *abstime); -PTW32_DLLPORT int __cdecl sem_post (sem_t * sem); +PTW32_DLLPORT int __cdecl sem_post(sem_t *sem); -PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem, - int count); +PTW32_DLLPORT int __cdecl sem_post_multiple(sem_t *sem, + int count); -PTW32_DLLPORT int __cdecl sem_open (const char * name, - int oflag, - mode_t mode, - unsigned int value); +PTW32_DLLPORT int __cdecl sem_open(const char *name, + int oflag, + mode_t mode, + unsigned int value); -PTW32_DLLPORT int __cdecl sem_close (sem_t * sem); +PTW32_DLLPORT int __cdecl sem_close(sem_t *sem); -PTW32_DLLPORT int __cdecl sem_unlink (const char * name); +PTW32_DLLPORT int __cdecl sem_unlink(const char *name); -PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, - int * sval); +PTW32_DLLPORT int __cdecl sem_getvalue(sem_t *sem, + int *sval); #if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ +} /* End of extern "C" */ +#endif /* __cplusplus */ #undef PTW32_SEMAPHORE_LEVEL #undef PTW32_SEMAPHORE_LEVEL_MAX -#endif /* !SEMAPHORE_H */ +#endif /* !SEMAPHORE_H */ diff --git a/software/src/nested_util.c b/software/src/nested_util.c index 6fee93f..430c473 100644 --- a/software/src/nested_util.c +++ b/software/src/nested_util.c @@ -75,13 +75,13 @@ countKeys *uniqsort(uint64_t *possibleKeys, uint32_t size) { } // nested decrypt -static void* nested_revover(void *args) { +static void *nested_revover(void *args) { struct Crypto1State *revstate, * revstate_start = NULL; uint64_t lfsr = 0; uint32_t i, kcount = 0; bool is_ok = true; - RecPar* rp = (RecPar*)args; + RecPar *rp = (RecPar *)args; rp->keyCount = 0; rp->keys = NULL; @@ -110,14 +110,14 @@ static void* nested_revover(void *args) { if (((kcount % MEM_CHUNK) == 0) || (kcount >= rp->keyCount)) { rp->keyCount += MEM_CHUNK; // printf("New chunk by %d, sizeof %lu\n", kcount, rp->keyCount * sizeof(uint64_t)); - void* tmp = realloc(rp->keys, rp->keyCount * sizeof(uint64_t)); + void *tmp = realloc(rp->keys, rp->keyCount * sizeof(uint64_t)); if (tmp == NULL) { printf("Memory allocation error for pk->possibleKeys"); rp->keyCount = 0; is_ok = false; break; } - rp->keys = (uint64_t*)tmp; + rp->keys = (uint64_t *)tmp; } rp->keys[kcount] = lfsr; kcount++; @@ -133,18 +133,16 @@ static void* nested_revover(void *args) { if (is_ok) { if (kcount != 0) { rp->keyCount = kcount; - void* tmp = (uint64_t*)realloc(rp->keys, rp->keyCount * sizeof(uint64_t)); + void *tmp = (uint64_t *)realloc(rp->keys, rp->keyCount * sizeof(uint64_t)); if (tmp == NULL) { printf("Memory allocation error for pk->possibleKeys"); rp->keyCount = 0; free(rp->keys); - } - else { + } else { rp->keys = tmp; } } - } - else { + } else { rp->keyCount = 0; free(rp->keys); } @@ -156,7 +154,7 @@ uint64_t *nested(NtpKs1 *pNK, uint32_t sizePNK, uint32_t authuid, uint32_t *keyC *keyCount = 0; uint32_t i, j, manyThread; - uint64_t* keys = (uint64_t*)NULL; + uint64_t *keys = (uint64_t *)NULL; manyThread = THREAD_MAX; if (manyThread > sizePNK) { @@ -164,11 +162,11 @@ uint64_t *nested(NtpKs1 *pNK, uint32_t sizePNK, uint32_t authuid, uint32_t *keyC } // pthread handle - pthread_t* threads = calloc(sizePNK, sizeof(pthread_t)); + pthread_t *threads = calloc(sizePNK, sizeof(pthread_t)); if (threads == NULL) return NULL; // Param - RecPar* pRPs = calloc(sizePNK, sizeof(RecPar)); + RecPar *pRPs = calloc(sizePNK, sizeof(RecPar)); if (pRPs == NULL) { free(threads); return NULL; @@ -216,9 +214,9 @@ uint64_t *nested(NtpKs1 *pNK, uint32_t sizePNK, uint32_t authuid, uint32_t *keyC } } - countKeys* ck = uniqsort(keys, *keyCount); + countKeys *ck = uniqsort(keys, *keyCount); free(keys); - keys = (uint64_t*)NULL; + keys = (uint64_t *)NULL; *keyCount = 0; if (ck != NULL) { @@ -227,24 +225,21 @@ uint64_t *nested(NtpKs1 *pNK, uint32_t sizePNK, uint32_t authuid, uint32_t *keyC // This key can be found here two or more times if (ck[i].count > 0) { *keyCount += 1; - void* tmp = realloc(keys, sizeof(uint64_t) * (*keyCount)); + void *tmp = realloc(keys, sizeof(uint64_t) * (*keyCount)); if (tmp != NULL) { keys = tmp; keys[*keyCount - 1] = ck[i].key; - } - else { + } else { printf("Cannot allocate memory for keys on merge."); free(keys); break; } } } - } - else { + } else { printf("Cannot allocate memory for ck on uniqsort."); } - } - else { + } else { printf("Cannot allocate memory to merge keys.\r\n"); } }