00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <stdio.h>
00015 #include "../fastlock.h"
00016
00017
00018
00019 int main(int argc, char** argv)
00020 {
00021 fl_lock_t lock;
00022 int r;
00023
00024 lock=0;
00025 printf("starting locking basic tests...\n");
00026
00027 r=try_lock(&lock);
00028 printf(" try_lock should return 0 ... %d\n", r);
00029 printf(" lock should be 1 now ... %d\n", lock);
00030 r=try_lock(&lock);
00031 printf(" tsl should return -1 ... %d\n", r);
00032 printf(" lock should still be 1 now ... %d\n", lock);
00033 release_lock(&lock);
00034 printf(" release_lock: lock should be 0 now ... %d\n", lock);
00035 printf("try_lock once more...\n");
00036 r=try_lock(&lock);
00037 printf(" try_lock should return 0 ... %d\n", r);
00038 printf(" lock should be 1 now ... %d\n", lock);
00039 release_lock(&lock);
00040 get_lock(&lock);
00041 printf(" get_lock, lock should be 1 now ... %d\n", lock);
00042 printf("\ndone.\n");
00043 return 0;
00044 }