]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/threads.c
Remove broken MSVC build from REL_ENG branch.
[openldap] / libraries / libldap_r / threads.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2003 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15
16 #include "portable.h"
17
18 #include <stdio.h>
19
20 #include <ac/stdarg.h>
21 #include <ac/stdlib.h>
22 #include <ac/string.h>
23 #include <ac/unistd.h>
24
25 #include "ldap_pvt_thread.h"
26
27
28 /*
29  * Common LDAP thread routines
30  *      see thr_*.c for implementation specific routines
31  *      see rdwr.c for generic reader/writer lock implementation
32  *      see tpool.c for generic thread pool implementation
33  */
34
35
36 int ldap_pvt_thread_initialize( void )
37 {
38         int rc;
39         static int init = 0;
40
41         /* we only get one shot at this */
42         if( init++ ) return -1;
43
44         rc = ldap_int_thread_initialize();
45         if( rc ) return rc;
46
47 #ifndef LDAP_THREAD_HAVE_TPOOL
48         rc = ldap_int_thread_pool_startup();
49         if( rc ) return rc;
50 #endif
51
52         return 0;
53 }
54
55 int ldap_pvt_thread_destroy( void )
56 {
57 #ifndef LDAP_THREAD_HAVE_TPOOL
58         (void) ldap_int_thread_pool_shutdown();
59 #endif
60         return ldap_int_thread_destroy();
61 }
62
63 #ifndef LDAP_THREAD_HAVE_GETCONCURRENCY
64 int
65 ldap_pvt_thread_get_concurrency ( void )
66 {
67         return 1;
68 }
69 #endif
70
71 #ifndef LDAP_THREAD_HAVE_SETCONCURRENCY
72 int
73 ldap_pvt_thread_set_concurrency ( int concurrency )
74 {
75         return 1;
76 }
77 #endif
78
79 #ifndef LDAP_THREAD_HAVE_SLEEP
80 /*
81  * Here we assume we have fully preemptive threads and that sleep()
82  * does the right thing.
83  */
84 unsigned int
85 ldap_pvt_thread_sleep(
86         unsigned int interval
87 )
88 {
89         sleep( interval );
90         return 0;
91 }
92 #endif