Home Libraries Author Links

system.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the SysToMath C Libraries package (LibStmC).
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Tom Michaelis, SysToMath.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2006
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 /******************************************************************************
00038  *                       First Release 1994-07-20
00039  ******************************************************************************/
00040 
00041 
00077 #ifndef STM_SYSTEM_H
00078 #define STM_SYSTEM_H
00079 
00080 
00081 /* Include header files and macro definitions. */
00082 #include <stm/internal/_system.h>
00083 
00084 
00085 #ifdef __cplusplus
00086     extern "C" {
00087 #endif
00088 
00089 
00109 StmDllSpec
00110 int stmGetkey (int fd);
00111 
00112 
00120 StmDllSpec
00121 StmInt64 stmGetMsTime (void);
00122 
00123 
00132 StmDllSpec
00133 StmInt64 stmGetMsCount (void);
00134 
00135 
00144 StmDllSpec
00145 void stmSleepMs (StmDword msecs);
00146 
00147 
00166 StmDllSpec
00167 int stmAtExit (void (*routine) (void));
00168 
00169 
00197 StmDllSpec
00198 pid_t stmProcessSpawn
00199 (
00200     const char *path,
00201     char *const argv [],
00202     StmBool usePath
00203 );
00204 
00205 
00222 StmDllSpec
00223 int stmProcessWait (pid_t pid, int *result);
00224 
00225 
00229 /* Include StmOnce, StmProcessSemaphore and StmSemaphore implementation types. */
00230 #include <stm/internal/_system.h>
00231 
00232 
00275 typedef StmOnceImpl_ StmOnce;
00276 
00277 
00282 #define StmOnceInit StmOnceInitImpl_
00283 
00284 
00308 StmDllSpec
00309 stm_inline int stmOnce (StmOnce *once, void (*routine) (void));
00310 
00311 
00352 StmAbstractTypeDefine (StmProcessSemaphore)  /* ProcessSemaphore */
00353 
00354 
00355 
00371 StmDllSpec
00372 StmProcessSemaphore stmProcessSemaphoreCreate (unsigned int value);
00373 
00374 
00391 StmDllSpec
00392 int stmProcessSemaphoreDestroy (StmProcessSemaphore semaphore);
00393 
00394 
00420 StmDllSpec
00421 int stmProcessSemaphoreAcquire (StmProcessSemaphore semaphore);
00422 
00423 
00445 StmDllSpec
00446 int stmProcessSemaphoreTryAcquire (StmProcessSemaphore semaphore);
00447 
00448 
00475 StmDllSpec
00476 int stmProcessSemaphoreTimedAcquire
00477 (
00478     StmProcessSemaphore semaphore,
00479     StmInt64 absTimeMs
00480 );
00481 
00482 
00501 StmDllSpec
00502 int stmProcessSemaphoreRelease (StmProcessSemaphore semaphore);
00503 
00504 
00525 enum StmSystemFlags
00526 {
00528     StmNoSystemFlag   = 0x0000,
00529 
00531     StmAttachExisting = 0x0010,
00532 
00534     StmAttachCreated  = 0x0020,
00535 
00537     StmAttach         = StmAttachExisting | StmAttachCreated,
00538 
00540     StmAttachMask     = StmAttach,
00541 
00543     StmKeepLocked     = 0x0040
00544 };
00545 
00546 
00585 StmAbstractTypeDefine (StmSemaphore)  /* Semaphore */
00586 
00587 
00588 
00637 StmDllSpec
00638 StmSemaphore stmSemaphoreCreate
00639 (
00640     const char *name,
00641     unsigned int value,
00642     unsigned int attach
00643 );
00644 
00645 
00664 StmDllSpec
00665 int stmSemaphoreDestroy (StmSemaphore semaphore);
00666 
00667 
00691 StmDllSpec
00692 int stmSemaphoreAdjustChild (StmSemaphore semaphore);
00693 
00694 
00705 StmDllSpec
00706 const char *stmSemaphoreName (StmSemaphore semaphore);
00707 
00708 
00727 StmDllSpec
00728 int stmSemaphoreAcquire (StmSemaphore semaphore);
00729 
00730 
00752 StmDllSpec
00753 int stmSemaphoreTryAcquire (StmSemaphore semaphore);
00754 
00755 
00782 StmDllSpec
00783 int stmSemaphoreTimedAcquire
00784 (
00785     StmSemaphore semaphore,
00786     StmInt64 absTimeMs
00787 );
00788 
00789 
00808 StmDllSpec
00809 int stmSemaphoreRelease (StmSemaphore semaphore);
00810 
00811 
00818 /* Include StmSharedMemory implementation types. */
00819 #include <stm/internal/_system.h>
00820 
00821 
00881 #define StmSharedMemoryItemDefine(ItemType, TimeoutMs)                         \
00882 StmSharedMemoryItemImpl_ (ItemType, TimeoutMs)
00883 
00884 
00888 /* Include StmMutex, StmNamedMutex, StmCondition, StmNamedCondition, StmThread
00889  * and StmThreadSpecific implementation types. */
00890 #include <stm/internal/_system.h>
00891 
00892 
00929 StmAbstractTypeDefine (StmMutex)  /* Mutex */
00930 
00931 
00932 
00952 StmDllSpec
00953 stm_inline StmMutex stmMutexCreate (StmBool recursive);
00954 
00955 
00971 StmDllSpec
00972 stm_inline int stmMutexDestroy (StmMutex mutex);
00973 
00974 
00995 StmDllSpec
00996 stm_inline int stmMutexLock (StmMutex mutex);
00997 
00998 
01015 StmDllSpec
01016 stm_inline int stmMutexTryLock (StmMutex mutex);
01017 
01018 
01038 StmDllSpec
01039 stm_inline int stmMutexTimedLock (StmMutex mutex, StmInt64 absTimeMs);
01040 
01041 
01054 StmDllSpec
01055 stm_inline int stmMutexUnlock (StmMutex mutex);
01056 
01057 
01100 StmAbstractTypeDefine (StmNamedMutex)  /* NamedMutex */
01101 
01102 
01154 StmDllSpec
01155 StmNamedMutex stmNamedMutexCreate
01156 (
01157     const char *name,
01158     StmBool recursive,
01159     unsigned int attach
01160 );
01161 
01162 
01181 StmDllSpec
01182 int stmNamedMutexDestroy (StmNamedMutex mutex);
01183 
01184 
01208 StmDllSpec
01209 int stmNamedMutexAdjustChild (StmNamedMutex mutex);
01210 
01211 
01222 StmDllSpec
01223 const char *stmNamedMutexName (StmNamedMutex mutex);
01224 
01225 
01242 StmDllSpec
01243 int stmNamedMutexLock (StmNamedMutex mutex);
01244 
01245 
01265 StmDllSpec
01266 int stmNamedMutexTryLock (StmNamedMutex mutex);
01267 
01268 
01291 StmDllSpec
01292 int stmNamedMutexTimedLock (StmNamedMutex mutex, StmInt64 absTimeMs);
01293 
01294 
01310 StmDllSpec
01311 int stmNamedMutexUnlock (StmNamedMutex mutex);
01312 
01313 
01358 StmAbstractTypeDefine (StmCondition)  /* Condition */
01359 
01360 
01376 StmDllSpec
01377 stm_inline StmCondition stmConditionCreate (void);
01378 
01379 
01395 StmDllSpec
01396 stm_inline int stmConditionDestroy (StmCondition cond);
01397 
01398 
01418 StmDllSpec
01419 stm_inline int stmConditionSignal (StmCondition cond);
01420 
01421 
01434 StmDllSpec
01435 stm_inline int stmConditionBroadcast (StmCondition cond);
01436 
01437 
01456 StmDllSpec
01457 stm_inline int stmConditionWait
01458 (
01459     StmCondition cond,
01460     StmMutex mutex
01461 );
01462 
01463 
01489 StmDllSpec
01490 stm_inline int stmConditionTimedWait
01491 (
01492     StmCondition cond,
01493     StmMutex mutex,
01494     StmInt64 absTimeMs
01495 );
01496 
01497 
01546 StmAbstractTypeDefine (StmNamedCondition)  /* NamedCondition */
01547 
01548 
01575 StmDllSpec
01576 StmNamedCondition stmNamedConditionCreate (const char *name);
01577 
01578 
01597 StmDllSpec
01598 int stmNamedConditionDestroy (StmNamedCondition cond);
01599 
01600 
01624 StmDllSpec
01625 int stmNamedConditionAdjustChild (StmNamedCondition cond);
01626 
01627 
01638 StmDllSpec
01639 const char *stmNamedConditionName (StmNamedCondition cond);
01640 
01641 
01657 StmDllSpec
01658 int stmNamedConditionSignal (StmNamedCondition cond);
01659 
01660 
01676 StmDllSpec
01677 int stmNamedConditionBroadcast (StmNamedCondition cond);
01678 
01679 
01701 StmDllSpec
01702 int stmNamedConditionWait
01703 (
01704     StmNamedCondition cond,
01705     StmNamedMutex mutex
01706 );
01707 
01708 
01737 StmDllSpec
01738 int stmNamedConditionTimedWait
01739 (
01740     StmNamedCondition cond,
01741     StmNamedMutex mutex,
01742     StmInt64 absTimeMs
01743 );
01744 
01745 
01769 StmAbstractTypeDefine (StmThread)  /* Thread */
01770 
01771 
01793 StmDllSpec
01794 StmThread stmThreadCreate
01795 (
01796     void * (*routine) (void *),
01797     void *arg
01798 );
01799 
01800 
01819 StmDllSpec
01820 stm_inline int stmThreadDestroy (StmThread thread);
01821 
01822 
01853 StmDllSpec
01854 int stmThreadAtExit (void (*routine) (void));
01855 
01856 
01865 StmDllSpec
01866 stm_inline StmThread stmThreadSelf (void);
01867 
01868 
01882 StmDllSpec
01883 stm_inline int stmThreadCmp (StmThread thread1, StmThread thread2);
01884 
01885 
01902 StmDllSpec
01903 stm_inline int stmThreadJoin (StmThread thread, void **pResult);
01904 
01905 
01944 StmAbstractTypeDefine (StmThreadSpecific)  /* ThreadSpecific */
01945 
01946 
01985 StmDllSpec
01986 stm_inline StmThreadSpecific stmThreadSpecificCreate
01987 (
01988     void (*destructor) (void *)
01989 );
01990 
01991 
02024 StmDllSpec
02025 stm_inline int stmThreadSpecificDestroy (StmThreadSpecific threadSpecific);
02026 
02027 
02052 StmDllSpec
02053 stm_inline void *stmThreadSpecificGet (StmThreadSpecific threadSpecific);
02054 
02055 
02080 StmDllSpec
02081 stm_inline int stmThreadSpecificSet
02082 (
02083     StmThreadSpecific threadSpecific,
02084     const void *value
02085 );
02086 
02087 
02094 #ifdef __cplusplus
02095 }
02096 #endif
02097 
02098 
02099 /* Include inline implementation. */
02100 #include <stm/internal/_system.h>
02101 
02102 
02103 #endif

© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).