Showing error 2211

User: Jiri Slaby
Error type: Reachable Error Location
Error type description: A specified error location is reachable in some program path
File location: pthread/sync01_safe.i
Line in file: 2071
Project: SV-COMP 2013
Project version: 2.6.28
Tools: Manual Work
Entered: 2013-01-17 16:57:54 UTC


Source:

   1# 1 "sync01.c"
   2# 1 "<built-in>"
   3# 1 "<command-line>"
   4# 1 "sync01.c"
   5# 1 "/usr/include/stdio.h" 1 3 4
   6# 28 "/usr/include/stdio.h" 3 4
   7# 1 "/usr/include/features.h" 1 3 4
   8# 363 "/usr/include/features.h" 3 4
   9# 1 "/usr/include/sys/cdefs.h" 1 3 4
  10# 372 "/usr/include/sys/cdefs.h" 3 4
  11# 1 "/usr/include/bits/wordsize.h" 1 3 4
  12# 373 "/usr/include/sys/cdefs.h" 2 3 4
  13# 364 "/usr/include/features.h" 2 3 4
  14# 387 "/usr/include/features.h" 3 4
  15# 1 "/usr/include/gnu/stubs.h" 1 3 4
  16
  17
  18
  19# 1 "/usr/include/bits/wordsize.h" 1 3 4
  20# 5 "/usr/include/gnu/stubs.h" 2 3 4
  21
  22
  23# 1 "/usr/include/gnu/stubs-32.h" 1 3 4
  24# 8 "/usr/include/gnu/stubs.h" 2 3 4
  25# 388 "/usr/include/features.h" 2 3 4
  26# 29 "/usr/include/stdio.h" 2 3 4
  27
  28
  29
  30
  31
  32# 1 "/usr/lib/gcc/i686-redhat-linux/4.6.3/include/stddef.h" 1 3 4
  33# 212 "/usr/lib/gcc/i686-redhat-linux/4.6.3/include/stddef.h" 3 4
  34typedef unsigned int size_t;
  35# 35 "/usr/include/stdio.h" 2 3 4
  36
  37# 1 "/usr/include/bits/types.h" 1 3 4
  38# 28 "/usr/include/bits/types.h" 3 4
  39# 1 "/usr/include/bits/wordsize.h" 1 3 4
  40# 29 "/usr/include/bits/types.h" 2 3 4
  41
  42
  43typedef unsigned char __u_char;
  44typedef unsigned short int __u_short;
  45typedef unsigned int __u_int;
  46typedef unsigned long int __u_long;
  47
  48
  49typedef signed char __int8_t;
  50typedef unsigned char __uint8_t;
  51typedef signed short int __int16_t;
  52typedef unsigned short int __uint16_t;
  53typedef signed int __int32_t;
  54typedef unsigned int __uint32_t;
  55
  56
  57
  58
  59__extension__ typedef signed long long int __int64_t;
  60__extension__ typedef unsigned long long int __uint64_t;
  61
  62
  63
  64
  65
  66
  67
  68__extension__ typedef long long int __quad_t;
  69__extension__ typedef unsigned long long int __u_quad_t;
  70# 131 "/usr/include/bits/types.h" 3 4
  71# 1 "/usr/include/bits/typesizes.h" 1 3 4
  72# 132 "/usr/include/bits/types.h" 2 3 4
  73
  74
  75__extension__ typedef __u_quad_t __dev_t;
  76__extension__ typedef unsigned int __uid_t;
  77__extension__ typedef unsigned int __gid_t;
  78__extension__ typedef unsigned long int __ino_t;
  79__extension__ typedef __u_quad_t __ino64_t;
  80__extension__ typedef unsigned int __mode_t;
  81__extension__ typedef unsigned int __nlink_t;
  82__extension__ typedef long int __off_t;
  83__extension__ typedef __quad_t __off64_t;
  84__extension__ typedef int __pid_t;
  85__extension__ typedef struct { int __val[2]; } __fsid_t;
  86__extension__ typedef long int __clock_t;
  87__extension__ typedef unsigned long int __rlim_t;
  88__extension__ typedef __u_quad_t __rlim64_t;
  89__extension__ typedef unsigned int __id_t;
  90__extension__ typedef long int __time_t;
  91__extension__ typedef unsigned int __useconds_t;
  92__extension__ typedef long int __suseconds_t;
  93
  94__extension__ typedef int __daddr_t;
  95__extension__ typedef long int __swblk_t;
  96__extension__ typedef int __key_t;
  97
  98
  99__extension__ typedef int __clockid_t;
 100
 101
 102__extension__ typedef void * __timer_t;
 103
 104
 105__extension__ typedef long int __blksize_t;
 106
 107
 108
 109
 110__extension__ typedef long int __blkcnt_t;
 111__extension__ typedef __quad_t __blkcnt64_t;
 112
 113
 114__extension__ typedef unsigned long int __fsblkcnt_t;
 115__extension__ typedef __u_quad_t __fsblkcnt64_t;
 116
 117
 118__extension__ typedef unsigned long int __fsfilcnt_t;
 119__extension__ typedef __u_quad_t __fsfilcnt64_t;
 120
 121__extension__ typedef int __ssize_t;
 122
 123
 124
 125typedef __off64_t __loff_t;
 126typedef __quad_t *__qaddr_t;
 127typedef char *__caddr_t;
 128
 129
 130__extension__ typedef int __intptr_t;
 131
 132
 133__extension__ typedef unsigned int __socklen_t;
 134# 37 "/usr/include/stdio.h" 2 3 4
 135# 45 "/usr/include/stdio.h" 3 4
 136struct _IO_FILE;
 137
 138
 139
 140typedef struct _IO_FILE FILE;
 141
 142
 143
 144
 145
 146# 65 "/usr/include/stdio.h" 3 4
 147typedef struct _IO_FILE __FILE;
 148# 75 "/usr/include/stdio.h" 3 4
 149# 1 "/usr/include/libio.h" 1 3 4
 150# 32 "/usr/include/libio.h" 3 4
 151# 1 "/usr/include/_G_config.h" 1 3 4
 152# 15 "/usr/include/_G_config.h" 3 4
 153# 1 "/usr/lib/gcc/i686-redhat-linux/4.6.3/include/stddef.h" 1 3 4
 154# 16 "/usr/include/_G_config.h" 2 3 4
 155
 156
 157
 158
 159# 1 "/usr/include/wchar.h" 1 3 4
 160# 83 "/usr/include/wchar.h" 3 4
 161typedef struct
 162{
 163  int __count;
 164  union
 165  {
 166
 167    unsigned int __wch;
 168
 169
 170
 171    char __wchb[4];
 172  } __value;
 173} __mbstate_t;
 174# 21 "/usr/include/_G_config.h" 2 3 4
 175
 176typedef struct
 177{
 178  __off_t __pos;
 179  __mbstate_t __state;
 180} _G_fpos_t;
 181typedef struct
 182{
 183  __off64_t __pos;
 184  __mbstate_t __state;
 185} _G_fpos64_t;
 186# 53 "/usr/include/_G_config.h" 3 4
 187typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
 188typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
 189typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
 190typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
 191# 33 "/usr/include/libio.h" 2 3 4
 192# 53 "/usr/include/libio.h" 3 4
 193# 1 "/usr/lib/gcc/i686-redhat-linux/4.6.3/include/stdarg.h" 1 3 4
 194# 40 "/usr/lib/gcc/i686-redhat-linux/4.6.3/include/stdarg.h" 3 4
 195typedef __builtin_va_list __gnuc_va_list;
 196# 54 "/usr/include/libio.h" 2 3 4
 197# 172 "/usr/include/libio.h" 3 4
 198struct _IO_jump_t; struct _IO_FILE;
 199# 182 "/usr/include/libio.h" 3 4
 200typedef void _IO_lock_t;
 201
 202
 203
 204
 205
 206struct _IO_marker {
 207  struct _IO_marker *_next;
 208  struct _IO_FILE *_sbuf;
 209
 210
 211
 212  int _pos;
 213# 205 "/usr/include/libio.h" 3 4
 214};
 215
 216
 217enum __codecvt_result
 218{
 219  __codecvt_ok,
 220  __codecvt_partial,
 221  __codecvt_error,
 222  __codecvt_noconv
 223};
 224# 273 "/usr/include/libio.h" 3 4
 225struct _IO_FILE {
 226  int _flags;
 227
 228
 229
 230
 231  char* _IO_read_ptr;
 232  char* _IO_read_end;
 233  char* _IO_read_base;
 234  char* _IO_write_base;
 235  char* _IO_write_ptr;
 236  char* _IO_write_end;
 237  char* _IO_buf_base;
 238  char* _IO_buf_end;
 239
 240  char *_IO_save_base;
 241  char *_IO_backup_base;
 242  char *_IO_save_end;
 243
 244  struct _IO_marker *_markers;
 245
 246  struct _IO_FILE *_chain;
 247
 248  int _fileno;
 249
 250
 251
 252  int _flags2;
 253
 254  __off_t _old_offset;
 255
 256
 257
 258  unsigned short _cur_column;
 259  signed char _vtable_offset;
 260  char _shortbuf[1];
 261
 262
 263
 264  _IO_lock_t *_lock;
 265# 321 "/usr/include/libio.h" 3 4
 266  __off64_t _offset;
 267# 330 "/usr/include/libio.h" 3 4
 268  void *__pad1;
 269  void *__pad2;
 270  void *__pad3;
 271  void *__pad4;
 272  size_t __pad5;
 273
 274  int _mode;
 275
 276  char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
 277
 278};
 279
 280
 281typedef struct _IO_FILE _IO_FILE;
 282
 283
 284struct _IO_FILE_plus;
 285
 286extern struct _IO_FILE_plus _IO_2_1_stdin_;
 287extern struct _IO_FILE_plus _IO_2_1_stdout_;
 288extern struct _IO_FILE_plus _IO_2_1_stderr_;
 289# 366 "/usr/include/libio.h" 3 4
 290typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
 291
 292
 293
 294
 295
 296
 297
 298typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
 299     size_t __n);
 300
 301
 302
 303
 304
 305
 306
 307typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
 308
 309
 310typedef int __io_close_fn (void *__cookie);
 311# 418 "/usr/include/libio.h" 3 4
 312extern int __underflow (_IO_FILE *);
 313extern int __uflow (_IO_FILE *);
 314extern int __overflow (_IO_FILE *, int);
 315# 462 "/usr/include/libio.h" 3 4
 316extern int _IO_getc (_IO_FILE *__fp);
 317extern int _IO_putc (int __c, _IO_FILE *__fp);
 318extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__));
 319extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__));
 320
 321extern int _IO_peekc_locked (_IO_FILE *__fp);
 322
 323
 324
 325
 326
 327extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__));
 328extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__));
 329extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__));
 330# 492 "/usr/include/libio.h" 3 4
 331extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
 332   __gnuc_va_list, int *__restrict);
 333extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
 334    __gnuc_va_list);
 335extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
 336extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
 337
 338extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
 339extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
 340
 341extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__));
 342# 76 "/usr/include/stdio.h" 2 3 4
 343
 344
 345
 346
 347typedef __gnuc_va_list va_list;
 348# 91 "/usr/include/stdio.h" 3 4
 349typedef __off_t off_t;
 350# 103 "/usr/include/stdio.h" 3 4
 351typedef __ssize_t ssize_t;
 352
 353
 354
 355
 356
 357
 358
 359typedef _G_fpos_t fpos_t;
 360
 361
 362
 363
 364# 165 "/usr/include/stdio.h" 3 4
 365# 1 "/usr/include/bits/stdio_lim.h" 1 3 4
 366# 166 "/usr/include/stdio.h" 2 3 4
 367
 368
 369
 370extern struct _IO_FILE *stdin;
 371extern struct _IO_FILE *stdout;
 372extern struct _IO_FILE *stderr;
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382extern int remove (__const char *__filename) __attribute__ ((__nothrow__));
 383
 384extern int rename (__const char *__old, __const char *__new) __attribute__ ((__nothrow__));
 385
 386
 387
 388
 389extern int renameat (int __oldfd, __const char *__old, int __newfd,
 390       __const char *__new) __attribute__ ((__nothrow__));
 391
 392
 393
 394
 395
 396
 397
 398
 399extern FILE *tmpfile (void) ;
 400# 212 "/usr/include/stdio.h" 3 4
 401extern char *tmpnam (char *__s) __attribute__ ((__nothrow__)) ;
 402
 403
 404
 405
 406
 407extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__)) ;
 408# 230 "/usr/include/stdio.h" 3 4
 409extern char *tempnam (__const char *__dir, __const char *__pfx)
 410     __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) ;
 411
 412
 413
 414
 415
 416
 417
 418
 419extern int fclose (FILE *__stream);
 420
 421
 422
 423
 424extern int fflush (FILE *__stream);
 425
 426# 255 "/usr/include/stdio.h" 3 4
 427extern int fflush_unlocked (FILE *__stream);
 428# 269 "/usr/include/stdio.h" 3 4
 429
 430
 431
 432
 433
 434
 435extern FILE *fopen (__const char *__restrict __filename,
 436      __const char *__restrict __modes) ;
 437
 438
 439
 440
 441extern FILE *freopen (__const char *__restrict __filename,
 442        __const char *__restrict __modes,
 443        FILE *__restrict __stream) ;
 444# 298 "/usr/include/stdio.h" 3 4
 445
 446# 309 "/usr/include/stdio.h" 3 4
 447extern FILE *fdopen (int __fd, __const char *__modes) __attribute__ ((__nothrow__)) ;
 448# 322 "/usr/include/stdio.h" 3 4
 449extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
 450  __attribute__ ((__nothrow__)) ;
 451
 452
 453
 454
 455extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__)) ;
 456
 457
 458
 459
 460
 461
 462extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__));
 463
 464
 465
 466extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
 467      int __modes, size_t __n) __attribute__ ((__nothrow__));
 468
 469
 470
 471
 472
 473extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
 474         size_t __size) __attribute__ ((__nothrow__));
 475
 476
 477extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__));
 478
 479
 480
 481
 482
 483
 484
 485
 486extern int fprintf (FILE *__restrict __stream,
 487      __const char *__restrict __format, ...);
 488
 489
 490
 491
 492extern int printf (__const char *__restrict __format, ...);
 493
 494extern int sprintf (char *__restrict __s,
 495      __const char *__restrict __format, ...) __attribute__ ((__nothrow__));
 496
 497
 498
 499
 500
 501extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
 502       __gnuc_va_list __arg);
 503
 504
 505
 506
 507extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
 508
 509extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
 510       __gnuc_va_list __arg) __attribute__ ((__nothrow__));
 511
 512
 513
 514
 515
 516extern int snprintf (char *__restrict __s, size_t __maxlen,
 517       __const char *__restrict __format, ...)
 518     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));
 519
 520extern int vsnprintf (char *__restrict __s, size_t __maxlen,
 521        __const char *__restrict __format, __gnuc_va_list __arg)
 522     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));
 523
 524# 420 "/usr/include/stdio.h" 3 4
 525extern int vdprintf (int __fd, __const char *__restrict __fmt,
 526       __gnuc_va_list __arg)
 527     __attribute__ ((__format__ (__printf__, 2, 0)));
 528extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
 529     __attribute__ ((__format__ (__printf__, 2, 3)));
 530
 531
 532
 533
 534
 535
 536
 537
 538extern int fscanf (FILE *__restrict __stream,
 539     __const char *__restrict __format, ...) ;
 540
 541
 542
 543
 544extern int scanf (__const char *__restrict __format, ...) ;
 545
 546extern int sscanf (__const char *__restrict __s,
 547     __const char *__restrict __format, ...) __attribute__ ((__nothrow__));
 548# 451 "/usr/include/stdio.h" 3 4
 549extern int fscanf (FILE *__restrict __stream, __const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf")
 550
 551                               ;
 552extern int scanf (__const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf")
 553                              ;
 554extern int sscanf (__const char *__restrict __s, __const char *__restrict __format, ...) __asm__ ("" "__isoc99_sscanf") __attribute__ ((__nothrow__))
 555
 556                      ;
 557# 471 "/usr/include/stdio.h" 3 4
 558
 559
 560
 561
 562
 563
 564
 565
 566extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
 567      __gnuc_va_list __arg)
 568     __attribute__ ((__format__ (__scanf__, 2, 0))) ;
 569
 570
 571
 572
 573
 574extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
 575     __attribute__ ((__format__ (__scanf__, 1, 0))) ;
 576
 577
 578extern int vsscanf (__const char *__restrict __s,
 579      __const char *__restrict __format, __gnuc_va_list __arg)
 580     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__scanf__, 2, 0)));
 581# 502 "/usr/include/stdio.h" 3 4
 582extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf")
 583
 584
 585
 586     __attribute__ ((__format__ (__scanf__, 2, 0))) ;
 587extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf")
 588
 589     __attribute__ ((__format__ (__scanf__, 1, 0))) ;
 590extern int vsscanf (__const char *__restrict __s, __const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__nothrow__))
 591
 592
 593
 594     __attribute__ ((__format__ (__scanf__, 2, 0)));
 595# 530 "/usr/include/stdio.h" 3 4
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605extern int fgetc (FILE *__stream);
 606extern int getc (FILE *__stream);
 607
 608
 609
 610
 611
 612extern int getchar (void);
 613
 614# 558 "/usr/include/stdio.h" 3 4
 615extern int getc_unlocked (FILE *__stream);
 616extern int getchar_unlocked (void);
 617# 569 "/usr/include/stdio.h" 3 4
 618extern int fgetc_unlocked (FILE *__stream);
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630extern int fputc (int __c, FILE *__stream);
 631extern int putc (int __c, FILE *__stream);
 632
 633
 634
 635
 636
 637extern int putchar (int __c);
 638
 639# 602 "/usr/include/stdio.h" 3 4
 640extern int fputc_unlocked (int __c, FILE *__stream);
 641
 642
 643
 644
 645
 646
 647
 648extern int putc_unlocked (int __c, FILE *__stream);
 649extern int putchar_unlocked (int __c);
 650
 651
 652
 653
 654
 655
 656extern int getw (FILE *__stream);
 657
 658
 659extern int putw (int __w, FILE *__stream);
 660
 661
 662
 663
 664
 665
 666
 667
 668extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
 669     ;
 670
 671
 672
 673
 674
 675
 676extern char *gets (char *__s) ;
 677
 678# 664 "/usr/include/stdio.h" 3 4
 679extern __ssize_t __getdelim (char **__restrict __lineptr,
 680          size_t *__restrict __n, int __delimiter,
 681          FILE *__restrict __stream) ;
 682extern __ssize_t getdelim (char **__restrict __lineptr,
 683        size_t *__restrict __n, int __delimiter,
 684        FILE *__restrict __stream) ;
 685
 686
 687
 688
 689
 690
 691
 692extern __ssize_t getline (char **__restrict __lineptr,
 693       size_t *__restrict __n,
 694       FILE *__restrict __stream) ;
 695
 696
 697
 698
 699
 700
 701
 702
 703extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
 704
 705
 706
 707
 708
 709extern int puts (__const char *__s);
 710
 711
 712
 713
 714
 715
 716extern int ungetc (int __c, FILE *__stream);
 717
 718
 719
 720
 721
 722
 723extern size_t fread (void *__restrict __ptr, size_t __size,
 724       size_t __n, FILE *__restrict __stream) ;
 725
 726
 727
 728
 729extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
 730        size_t __n, FILE *__restrict __s) ;
 731
 732# 736 "/usr/include/stdio.h" 3 4
 733extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
 734         size_t __n, FILE *__restrict __stream) ;
 735extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
 736          size_t __n, FILE *__restrict __stream) ;
 737
 738
 739
 740
 741
 742
 743
 744
 745extern int fseek (FILE *__stream, long int __off, int __whence);
 746
 747
 748
 749
 750extern long int ftell (FILE *__stream) ;
 751
 752
 753
 754
 755extern void rewind (FILE *__stream);
 756
 757# 772 "/usr/include/stdio.h" 3 4
 758extern int fseeko (FILE *__stream, __off_t __off, int __whence);
 759
 760
 761
 762
 763extern __off_t ftello (FILE *__stream) ;
 764# 791 "/usr/include/stdio.h" 3 4
 765
 766
 767
 768
 769
 770
 771extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
 772
 773
 774
 775
 776extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
 777# 814 "/usr/include/stdio.h" 3 4
 778
 779# 823 "/usr/include/stdio.h" 3 4
 780
 781
 782extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__));
 783
 784extern int feof (FILE *__stream) __attribute__ ((__nothrow__)) ;
 785
 786extern int ferror (FILE *__stream) __attribute__ ((__nothrow__)) ;
 787
 788
 789
 790
 791extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__));
 792extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__)) ;
 793extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__)) ;
 794
 795
 796
 797
 798
 799
 800
 801
 802extern void perror (__const char *__s);
 803
 804
 805
 806
 807
 808
 809# 1 "/usr/include/bits/sys_errlist.h" 1 3 4
 810# 27 "/usr/include/bits/sys_errlist.h" 3 4
 811extern int sys_nerr;
 812extern __const char *__const sys_errlist[];
 813# 853 "/usr/include/stdio.h" 2 3 4
 814
 815
 816
 817
 818extern int fileno (FILE *__stream) __attribute__ ((__nothrow__)) ;
 819
 820
 821
 822
 823extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__)) ;
 824# 872 "/usr/include/stdio.h" 3 4
 825extern FILE *popen (__const char *__command, __const char *__modes) ;
 826
 827
 828
 829
 830
 831extern int pclose (FILE *__stream);
 832
 833
 834
 835
 836
 837extern char *ctermid (char *__s) __attribute__ ((__nothrow__));
 838# 912 "/usr/include/stdio.h" 3 4
 839extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__));
 840
 841
 842
 843extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__)) ;
 844
 845
 846extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__));
 847# 942 "/usr/include/stdio.h" 3 4
 848
 849# 2 "sync01.c" 2
 850# 1 "/usr/include/pthread.h" 1 3 4
 851# 24 "/usr/include/pthread.h" 3 4
 852# 1 "/usr/include/endian.h" 1 3 4
 853# 37 "/usr/include/endian.h" 3 4
 854# 1 "/usr/include/bits/endian.h" 1 3 4
 855# 38 "/usr/include/endian.h" 2 3 4
 856# 61 "/usr/include/endian.h" 3 4
 857# 1 "/usr/include/bits/byteswap.h" 1 3 4
 858# 62 "/usr/include/endian.h" 2 3 4
 859# 25 "/usr/include/pthread.h" 2 3 4
 860# 1 "/usr/include/sched.h" 1 3 4
 861# 30 "/usr/include/sched.h" 3 4
 862# 1 "/usr/lib/gcc/i686-redhat-linux/4.6.3/include/stddef.h" 1 3 4
 863# 31 "/usr/include/sched.h" 2 3 4
 864
 865
 866
 867# 1 "/usr/include/time.h" 1 3 4
 868# 74 "/usr/include/time.h" 3 4
 869
 870
 871typedef __time_t time_t;
 872
 873
 874
 875# 120 "/usr/include/time.h" 3 4
 876struct timespec
 877  {
 878    __time_t tv_sec;
 879    long int tv_nsec;
 880  };
 881# 35 "/usr/include/sched.h" 2 3 4
 882
 883
 884typedef __pid_t pid_t;
 885
 886
 887
 888
 889
 890# 1 "/usr/include/bits/sched.h" 1 3 4
 891# 74 "/usr/include/bits/sched.h" 3 4
 892struct sched_param
 893  {
 894    int __sched_priority;
 895  };
 896
 897
 898# 97 "/usr/include/bits/sched.h" 3 4
 899
 900
 901
 902
 903
 904
 905
 906
 907struct __sched_param
 908  {
 909    int __sched_priority;
 910  };
 911# 120 "/usr/include/bits/sched.h" 3 4
 912typedef unsigned long int __cpu_mask;
 913
 914
 915
 916
 917
 918
 919typedef struct
 920{
 921  __cpu_mask __bits[1024 / (8 * sizeof (__cpu_mask))];
 922} cpu_set_t;
 923# 203 "/usr/include/bits/sched.h" 3 4
 924
 925
 926extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
 927  __attribute__ ((__nothrow__));
 928extern cpu_set_t *__sched_cpualloc (size_t __count) __attribute__ ((__nothrow__)) ;
 929extern void __sched_cpufree (cpu_set_t *__set) __attribute__ ((__nothrow__));
 930
 931
 932# 44 "/usr/include/sched.h" 2 3 4
 933
 934
 935
 936
 937
 938
 939
 940extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param)
 941     __attribute__ ((__nothrow__));
 942
 943
 944extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __attribute__ ((__nothrow__));
 945
 946
 947extern int sched_setscheduler (__pid_t __pid, int __policy,
 948          __const struct sched_param *__param) __attribute__ ((__nothrow__));
 949
 950
 951extern int sched_getscheduler (__pid_t __pid) __attribute__ ((__nothrow__));
 952
 953
 954extern int sched_yield (void) __attribute__ ((__nothrow__));
 955
 956
 957extern int sched_get_priority_max (int __algorithm) __attribute__ ((__nothrow__));
 958
 959
 960extern int sched_get_priority_min (int __algorithm) __attribute__ ((__nothrow__));
 961
 962
 963extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __attribute__ ((__nothrow__));
 964# 126 "/usr/include/sched.h" 3 4
 965
 966# 26 "/usr/include/pthread.h" 2 3 4
 967# 1 "/usr/include/time.h" 1 3 4
 968# 30 "/usr/include/time.h" 3 4
 969
 970
 971
 972
 973
 974
 975
 976
 977# 1 "/usr/lib/gcc/i686-redhat-linux/4.6.3/include/stddef.h" 1 3 4
 978# 39 "/usr/include/time.h" 2 3 4
 979
 980
 981
 982# 1 "/usr/include/bits/time.h" 1 3 4
 983# 43 "/usr/include/time.h" 2 3 4
 984# 58 "/usr/include/time.h" 3 4
 985
 986
 987typedef __clock_t clock_t;
 988
 989
 990
 991# 92 "/usr/include/time.h" 3 4
 992typedef __clockid_t clockid_t;
 993# 104 "/usr/include/time.h" 3 4
 994typedef __timer_t timer_t;
 995# 131 "/usr/include/time.h" 3 4
 996
 997
 998struct tm
 999{
1000  int tm_sec;
1001  int tm_min;
1002  int tm_hour;
1003  int tm_mday;
1004  int tm_mon;
1005  int tm_year;
1006  int tm_wday;
1007  int tm_yday;
1008  int tm_isdst;
1009
1010
1011  long int tm_gmtoff;
1012  __const char *tm_zone;
1013
1014
1015
1016
1017};
1018
1019
1020
1021
1022
1023
1024
1025
1026struct itimerspec
1027  {
1028    struct timespec it_interval;
1029    struct timespec it_value;
1030  };
1031
1032
1033struct sigevent;
1034# 180 "/usr/include/time.h" 3 4
1035
1036
1037
1038extern clock_t clock (void) __attribute__ ((__nothrow__));
1039
1040
1041extern time_t time (time_t *__timer) __attribute__ ((__nothrow__));
1042
1043
1044extern double difftime (time_t __time1, time_t __time0)
1045     __attribute__ ((__nothrow__)) __attribute__ ((__const__));
1046
1047
1048extern time_t mktime (struct tm *__tp) __attribute__ ((__nothrow__));
1049
1050
1051
1052
1053
1054extern size_t strftime (char *__restrict __s, size_t __maxsize,
1055   __const char *__restrict __format,
1056   __const struct tm *__restrict __tp) __attribute__ ((__nothrow__));
1057
1058# 215 "/usr/include/time.h" 3 4
1059# 1 "/usr/include/xlocale.h" 1 3 4
1060# 28 "/usr/include/xlocale.h" 3 4
1061typedef struct __locale_struct
1062{
1063
1064  struct __locale_data *__locales[13];
1065
1066
1067  const unsigned short int *__ctype_b;
1068  const int *__ctype_tolower;
1069  const int *__ctype_toupper;
1070
1071
1072  const char *__names[13];
1073} *__locale_t;
1074
1075
1076typedef __locale_t locale_t;
1077# 216 "/usr/include/time.h" 2 3 4
1078
1079extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
1080     __const char *__restrict __format,
1081     __const struct tm *__restrict __tp,
1082     __locale_t __loc) __attribute__ ((__nothrow__));
1083# 230 "/usr/include/time.h" 3 4
1084
1085
1086
1087extern struct tm *gmtime (__const time_t *__timer) __attribute__ ((__nothrow__));
1088
1089
1090
1091extern struct tm *localtime (__const time_t *__timer) __attribute__ ((__nothrow__));
1092
1093
1094
1095
1096
1097extern struct tm *gmtime_r (__const time_t *__restrict __timer,
1098       struct tm *__restrict __tp) __attribute__ ((__nothrow__));
1099
1100
1101
1102extern struct tm *localtime_r (__const time_t *__restrict __timer,
1103          struct tm *__restrict __tp) __attribute__ ((__nothrow__));
1104
1105
1106
1107
1108
1109extern char *asctime (__const struct tm *__tp) __attribute__ ((__nothrow__));
1110
1111
1112extern char *ctime (__const time_t *__timer) __attribute__ ((__nothrow__));
1113
1114
1115
1116
1117
1118
1119
1120extern char *asctime_r (__const struct tm *__restrict __tp,
1121   char *__restrict __buf) __attribute__ ((__nothrow__));
1122
1123
1124extern char *ctime_r (__const time_t *__restrict __timer,
1125        char *__restrict __buf) __attribute__ ((__nothrow__));
1126
1127
1128
1129
1130extern char *__tzname[2];
1131extern int __daylight;
1132extern long int __timezone;
1133
1134
1135
1136
1137extern char *tzname[2];
1138
1139
1140
1141extern void tzset (void) __attribute__ ((__nothrow__));
1142
1143
1144
1145extern int daylight;
1146extern long int timezone;
1147
1148
1149
1150
1151
1152extern int stime (__const time_t *__when) __attribute__ ((__nothrow__));
1153# 313 "/usr/include/time.h" 3 4
1154extern time_t timegm (struct tm *__tp) __attribute__ ((__nothrow__));
1155
1156
1157extern time_t timelocal (struct tm *__tp) __attribute__ ((__nothrow__));
1158
1159
1160extern int dysize (int __year) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
1161# 328 "/usr/include/time.h" 3 4
1162extern int nanosleep (__const struct timespec *__requested_time,
1163        struct timespec *__remaining);
1164
1165
1166
1167extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __attribute__ ((__nothrow__));
1168
1169
1170extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __attribute__ ((__nothrow__));
1171
1172
1173extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp)
1174     __attribute__ ((__nothrow__));
1175
1176
1177
1178
1179
1180
1181extern int clock_nanosleep (clockid_t __clock_id, int __flags,
1182       __const struct timespec *__req,
1183       struct timespec *__rem);
1184
1185
1186extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __attribute__ ((__nothrow__));
1187
1188
1189
1190
1191extern int timer_create (clockid_t __clock_id,
1192    struct sigevent *__restrict __evp,
1193    timer_t *__restrict __timerid) __attribute__ ((__nothrow__));
1194
1195
1196extern int timer_delete (timer_t __timerid) __attribute__ ((__nothrow__));
1197
1198
1199extern int timer_settime (timer_t __timerid, int __flags,
1200     __const struct itimerspec *__restrict __value,
1201     struct itimerspec *__restrict __ovalue) __attribute__ ((__nothrow__));
1202
1203
1204extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
1205     __attribute__ ((__nothrow__));
1206
1207
1208extern int timer_getoverrun (timer_t __timerid) __attribute__ ((__nothrow__));
1209# 417 "/usr/include/time.h" 3 4
1210
1211# 27 "/usr/include/pthread.h" 2 3 4
1212
1213# 1 "/usr/include/bits/pthreadtypes.h" 1 3 4
1214# 36 "/usr/include/bits/pthreadtypes.h" 3 4
1215typedef unsigned long int pthread_t;
1216
1217
1218typedef union
1219{
1220  char __size[36];
1221  long int __align;
1222} pthread_attr_t;
1223
1224
1225typedef struct __pthread_internal_slist
1226{
1227  struct __pthread_internal_slist *__next;
1228} __pthread_slist_t;
1229
1230
1231
1232
1233typedef union
1234{
1235  struct __pthread_mutex_s
1236  {
1237    int __lock;
1238    unsigned int __count;
1239    int __owner;
1240
1241
1242    int __kind;
1243    unsigned int __nusers;
1244    __extension__ union
1245    {
1246      int __spins;
1247      __pthread_slist_t __list;
1248    };
1249  } __data;
1250  char __size[24];
1251  long int __align;
1252} pthread_mutex_t;
1253
1254typedef union
1255{
1256  char __size[4];
1257  long int __align;
1258} pthread_mutexattr_t;
1259
1260
1261
1262
1263typedef union
1264{
1265  struct
1266  {
1267    int __lock;
1268    unsigned int __futex;
1269    __extension__ unsigned long long int __total_seq;
1270    __extension__ unsigned long long int __wakeup_seq;
1271    __extension__ unsigned long long int __woken_seq;
1272    void *__mutex;
1273    unsigned int __nwaiters;
1274    unsigned int __broadcast_seq;
1275  } __data;
1276  char __size[48];
1277  __extension__ long long int __align;
1278} pthread_cond_t;
1279
1280typedef union
1281{
1282  char __size[4];
1283  long int __align;
1284} pthread_condattr_t;
1285
1286
1287
1288typedef unsigned int pthread_key_t;
1289
1290
1291
1292typedef int pthread_once_t;
1293
1294
1295
1296
1297
1298typedef union
1299{
1300  struct
1301  {
1302    int __lock;
1303    unsigned int __nr_readers;
1304    unsigned int __readers_wakeup;
1305    unsigned int __writer_wakeup;
1306    unsigned int __nr_readers_queued;
1307    unsigned int __nr_writers_queued;
1308
1309
1310    unsigned char __flags;
1311    unsigned char __shared;
1312    unsigned char __pad1;
1313    unsigned char __pad2;
1314    int __writer;
1315  } __data;
1316  char __size[32];
1317  long int __align;
1318} pthread_rwlock_t;
1319
1320typedef union
1321{
1322  char __size[8];
1323  long int __align;
1324} pthread_rwlockattr_t;
1325
1326
1327
1328
1329
1330typedef volatile int pthread_spinlock_t;
1331
1332
1333
1334
1335typedef union
1336{
1337  char __size[20];
1338  long int __align;
1339} pthread_barrier_t;
1340
1341typedef union
1342{
1343  char __size[4];
1344  int __align;
1345} pthread_barrierattr_t;
1346# 29 "/usr/include/pthread.h" 2 3 4
1347# 1 "/usr/include/bits/setjmp.h" 1 3 4
1348# 29 "/usr/include/bits/setjmp.h" 3 4
1349typedef int __jmp_buf[6];
1350# 30 "/usr/include/pthread.h" 2 3 4
1351# 1 "/usr/include/bits/wordsize.h" 1 3 4
1352# 31 "/usr/include/pthread.h" 2 3 4
1353
1354
1355
1356enum
1357{
1358  PTHREAD_CREATE_JOINABLE,
1359
1360  PTHREAD_CREATE_DETACHED
1361
1362};
1363
1364
1365
1366enum
1367{
1368  PTHREAD_MUTEX_TIMED_NP,
1369  PTHREAD_MUTEX_RECURSIVE_NP,
1370  PTHREAD_MUTEX_ERRORCHECK_NP,
1371  PTHREAD_MUTEX_ADAPTIVE_NP
1372
1373  ,
1374  PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
1375  PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
1376  PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
1377  PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
1378
1379
1380
1381
1382
1383};
1384
1385
1386
1387
1388enum
1389{
1390  PTHREAD_MUTEX_STALLED,
1391  PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
1392  PTHREAD_MUTEX_ROBUST,
1393  PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
1394};
1395# 115 "/usr/include/pthread.h" 3 4
1396enum
1397{
1398  PTHREAD_RWLOCK_PREFER_READER_NP,
1399  PTHREAD_RWLOCK_PREFER_WRITER_NP,
1400  PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
1401  PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
1402};
1403# 147 "/usr/include/pthread.h" 3 4
1404enum
1405{
1406  PTHREAD_INHERIT_SCHED,
1407
1408  PTHREAD_EXPLICIT_SCHED
1409
1410};
1411
1412
1413
1414enum
1415{
1416  PTHREAD_SCOPE_SYSTEM,
1417
1418  PTHREAD_SCOPE_PROCESS
1419
1420};
1421
1422
1423
1424enum
1425{
1426  PTHREAD_PROCESS_PRIVATE,
1427
1428  PTHREAD_PROCESS_SHARED
1429
1430};
1431# 182 "/usr/include/pthread.h" 3 4
1432struct _pthread_cleanup_buffer
1433{
1434  void (*__routine) (void *);
1435  void *__arg;
1436  int __canceltype;
1437  struct _pthread_cleanup_buffer *__prev;
1438};
1439
1440
1441enum
1442{
1443  PTHREAD_CANCEL_ENABLE,
1444
1445  PTHREAD_CANCEL_DISABLE
1446
1447};
1448enum
1449{
1450  PTHREAD_CANCEL_DEFERRED,
1451
1452  PTHREAD_CANCEL_ASYNCHRONOUS
1453
1454};
1455# 220 "/usr/include/pthread.h" 3 4
1456
1457
1458
1459
1460
1461extern int pthread_create (pthread_t *__restrict __newthread,
1462      __const pthread_attr_t *__restrict __attr,
1463      void *(*__start_routine) (void *),
1464      void *__restrict __arg) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 3)));
1465
1466
1467
1468
1469
1470extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
1471
1472
1473
1474
1475
1476
1477
1478extern int pthread_join (pthread_t __th, void **__thread_return);
1479# 263 "/usr/include/pthread.h" 3 4
1480extern int pthread_detach (pthread_t __th) __attribute__ ((__nothrow__));
1481
1482
1483
1484extern pthread_t pthread_self (void) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
1485
1486
1487extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __attribute__ ((__nothrow__));
1488
1489
1490
1491
1492
1493
1494
1495extern int pthread_attr_init (pthread_attr_t *__attr) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1496
1497
1498extern int pthread_attr_destroy (pthread_attr_t *__attr)
1499     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1500
1501
1502extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
1503     int *__detachstate)
1504     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1505
1506
1507extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
1508     int __detachstate)
1509     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1510
1511
1512
1513extern int pthread_attr_getguardsize (__const pthread_attr_t *__attr,
1514          size_t *__guardsize)
1515     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1516
1517
1518extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
1519          size_t __guardsize)
1520     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1521
1522
1523
1524extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
1525           __attr,
1526           struct sched_param *__restrict __param)
1527     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1528
1529
1530extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
1531           __const struct sched_param *__restrict
1532           __param) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1533
1534
1535extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
1536     __attr, int *__restrict __policy)
1537     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1538
1539
1540extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
1541     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1542
1543
1544extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
1545      __attr, int *__restrict __inherit)
1546     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1547
1548
1549extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
1550      int __inherit)
1551     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1552
1553
1554
1555extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
1556      int *__restrict __scope)
1557     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1558
1559
1560extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
1561     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1562
1563
1564extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
1565          __attr, void **__restrict __stackaddr)
1566     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__deprecated__));
1567
1568
1569
1570
1571
1572extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
1573          void *__stackaddr)
1574     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__));
1575
1576
1577extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
1578          __attr, size_t *__restrict __stacksize)
1579     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1580
1581
1582
1583
1584extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
1585          size_t __stacksize)
1586     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1587
1588
1589
1590extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
1591      void **__restrict __stackaddr,
1592      size_t *__restrict __stacksize)
1593     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2, 3)));
1594
1595
1596
1597
1598extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
1599      size_t __stacksize) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1600# 413 "/usr/include/pthread.h" 3 4
1601extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
1602      __const struct sched_param *__param)
1603     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3)));
1604
1605
1606extern int pthread_getschedparam (pthread_t __target_thread,
1607      int *__restrict __policy,
1608      struct sched_param *__restrict __param)
1609     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
1610
1611
1612extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
1613     __attribute__ ((__nothrow__));
1614# 478 "/usr/include/pthread.h" 3 4
1615extern int pthread_once (pthread_once_t *__once_control,
1616    void (*__init_routine) (void)) __attribute__ ((__nonnull__ (1, 2)));
1617# 490 "/usr/include/pthread.h" 3 4
1618extern int pthread_setcancelstate (int __state, int *__oldstate);
1619
1620
1621
1622extern int pthread_setcanceltype (int __type, int *__oldtype);
1623
1624
1625extern int pthread_cancel (pthread_t __th);
1626
1627
1628
1629
1630extern void pthread_testcancel (void);
1631
1632
1633
1634
1635typedef struct
1636{
1637  struct
1638  {
1639    __jmp_buf __cancel_jmp_buf;
1640    int __mask_was_saved;
1641  } __cancel_jmp_buf[1];
1642  void *__pad[4];
1643} __pthread_unwind_buf_t __attribute__ ((__aligned__));
1644# 524 "/usr/include/pthread.h" 3 4
1645struct __pthread_cleanup_frame
1646{
1647  void (*__cancel_routine) (void *);
1648  void *__cancel_arg;
1649  int __do_it;
1650  int __cancel_type;
1651};
1652# 664 "/usr/include/pthread.h" 3 4
1653extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
1654     __attribute__ ((__regparm__ (1)));
1655# 676 "/usr/include/pthread.h" 3 4
1656extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
1657  __attribute__ ((__regparm__ (1)));
1658# 717 "/usr/include/pthread.h" 3 4
1659extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
1660     __attribute__ ((__regparm__ (1))) __attribute__ ((__noreturn__))
1661
1662     __attribute__ ((__weak__))
1663
1664     ;
1665
1666
1667
1668struct __jmp_buf_tag;
1669extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __attribute__ ((__nothrow__));
1670
1671
1672
1673
1674
1675extern int pthread_mutex_init (pthread_mutex_t *__mutex,
1676          __const pthread_mutexattr_t *__mutexattr)
1677     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1678
1679
1680extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
1681     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1682
1683
1684extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
1685     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1686
1687
1688extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
1689     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1690
1691
1692
1693extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
1694        __const struct timespec *__restrict
1695        __abstime) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1696
1697
1698
1699extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
1700     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1701
1702
1703
1704extern int pthread_mutex_getprioceiling (__const pthread_mutex_t *
1705      __restrict __mutex,
1706      int *__restrict __prioceiling)
1707     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1708
1709
1710
1711extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
1712      int __prioceiling,
1713      int *__restrict __old_ceiling)
1714     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 3)));
1715
1716
1717
1718
1719extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
1720     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1721# 790 "/usr/include/pthread.h" 3 4
1722extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
1723     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1724
1725
1726extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
1727     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1728
1729
1730extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
1731      __restrict __attr,
1732      int *__restrict __pshared)
1733     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1734
1735
1736extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
1737      int __pshared)
1738     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1739
1740
1741
1742extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
1743          __attr, int *__restrict __kind)
1744     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1745
1746
1747
1748
1749extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
1750     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1751
1752
1753
1754extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t *
1755       __restrict __attr,
1756       int *__restrict __protocol)
1757     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1758
1759
1760
1761extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
1762       int __protocol)
1763     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1764
1765
1766extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t *
1767          __restrict __attr,
1768          int *__restrict __prioceiling)
1769     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1770
1771
1772extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
1773          int __prioceiling)
1774     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1775
1776
1777
1778extern int pthread_mutexattr_getrobust (__const pthread_mutexattr_t *__attr,
1779     int *__robustness)
1780     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1781
1782
1783
1784
1785
1786
1787
1788extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
1789     int __robustness)
1790     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1791# 872 "/usr/include/pthread.h" 3 4
1792extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
1793    __const pthread_rwlockattr_t *__restrict
1794    __attr) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1795
1796
1797extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
1798     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1799
1800
1801extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
1802     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1803
1804
1805extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
1806  __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1807
1808
1809
1810extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
1811           __const struct timespec *__restrict
1812           __abstime) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1813
1814
1815
1816extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
1817     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1818
1819
1820extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
1821     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1822
1823
1824
1825extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
1826           __const struct timespec *__restrict
1827           __abstime) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1828
1829
1830
1831extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
1832     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1833
1834
1835
1836
1837
1838extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
1839     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1840
1841
1842extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
1843     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1844
1845
1846extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
1847       __restrict __attr,
1848       int *__restrict __pshared)
1849     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1850
1851
1852extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
1853       int __pshared)
1854     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1855
1856
1857extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *
1858       __restrict __attr,
1859       int *__restrict __pref)
1860     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1861
1862
1863extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
1864       int __pref) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1865
1866
1867
1868
1869
1870
1871
1872extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
1873         __const pthread_condattr_t *__restrict
1874         __cond_attr) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1875
1876
1877extern int pthread_cond_destroy (pthread_cond_t *__cond)
1878     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1879
1880
1881extern int pthread_cond_signal (pthread_cond_t *__cond)
1882     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1883
1884
1885extern int pthread_cond_broadcast (pthread_cond_t *__cond)
1886     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1887
1888
1889
1890
1891
1892
1893extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
1894         pthread_mutex_t *__restrict __mutex)
1895     __attribute__ ((__nonnull__ (1, 2)));
1896# 984 "/usr/include/pthread.h" 3 4
1897extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
1898       pthread_mutex_t *__restrict __mutex,
1899       __const struct timespec *__restrict
1900       __abstime) __attribute__ ((__nonnull__ (1, 2, 3)));
1901
1902
1903
1904
1905extern int pthread_condattr_init (pthread_condattr_t *__attr)
1906     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1907
1908
1909extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
1910     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1911
1912
1913extern int pthread_condattr_getpshared (__const pthread_condattr_t *
1914     __restrict __attr,
1915     int *__restrict __pshared)
1916     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1917
1918
1919extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
1920     int __pshared) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1921
1922
1923
1924extern int pthread_condattr_getclock (__const pthread_condattr_t *
1925          __restrict __attr,
1926          __clockid_t *__restrict __clock_id)
1927     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1928
1929
1930extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
1931          __clockid_t __clock_id)
1932     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1933# 1028 "/usr/include/pthread.h" 3 4
1934extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
1935     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1936
1937
1938extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
1939     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1940
1941
1942extern int pthread_spin_lock (pthread_spinlock_t *__lock)
1943     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1944
1945
1946extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
1947     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1948
1949
1950extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
1951     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1952
1953
1954
1955
1956
1957
1958extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1959     __const pthread_barrierattr_t *__restrict
1960     __attr, unsigned int __count)
1961     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1962
1963
1964extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1965     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1966
1967
1968extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1969     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1970
1971
1972
1973extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
1974     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1975
1976
1977extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
1978     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1979
1980
1981extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
1982        __restrict __attr,
1983        int *__restrict __pshared)
1984     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
1985
1986
1987extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
1988        int __pshared)
1989     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1990# 1095 "/usr/include/pthread.h" 3 4
1991extern int pthread_key_create (pthread_key_t *__key,
1992          void (*__destr_function) (void *))
1993     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
1994
1995
1996extern int pthread_key_delete (pthread_key_t __key) __attribute__ ((__nothrow__));
1997
1998
1999extern void *pthread_getspecific (pthread_key_t __key) __attribute__ ((__nothrow__));
2000
2001
2002extern int pthread_setspecific (pthread_key_t __key,
2003    __const void *__pointer) __attribute__ ((__nothrow__)) ;
2004
2005
2006
2007
2008extern int pthread_getcpuclockid (pthread_t __thread_id,
2009      __clockid_t *__clock_id)
2010     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
2011# 1129 "/usr/include/pthread.h" 3 4
2012extern int pthread_atfork (void (*__prepare) (void),
2013      void (*__parent) (void),
2014      void (*__child) (void)) __attribute__ ((__nothrow__));
2015# 1143 "/usr/include/pthread.h" 3 4
2016
2017# 3 "sync01.c" 2
2018
2019int num;
2020
2021pthread_mutex_t m;
2022pthread_cond_t empty, full;
2023
2024void * thread1(void * arg)
2025{
2026  pthread_mutex_lock(&m);
2027
2028  while (num > 0)
2029    pthread_cond_wait(&empty, &m);
2030
2031  num++;
2032
2033  pthread_mutex_unlock(&m);
2034  pthread_cond_signal(&full);
2035}
2036
2037
2038void * thread2(void * arg)
2039{
2040  pthread_mutex_lock(&m);
2041
2042  while (num == 0)
2043    pthread_cond_wait(&full, &m);
2044
2045  num--;
2046
2047  pthread_mutex_unlock(&m);
2048
2049  pthread_cond_signal(&empty);
2050}
2051
2052
2053int main()
2054{
2055  pthread_t t1, t2;
2056
2057  num = 1;
2058
2059  pthread_mutex_init(&m, 0);
2060  pthread_cond_init(&empty, 0);
2061  pthread_cond_init(&full, 0);
2062
2063  pthread_create(&t1, 0, thread1, 0);
2064  pthread_create(&t2, 0, thread2, 0);
2065
2066  pthread_join(t1, 0);
2067  pthread_join(t2, 0);
2068
2069  if (num!=1)
2070  {
2071    ERROR: goto ERROR;
2072    ;
2073  }
2074
2075  return 0;
2076
2077}