This file is indexed.

/usr/include/pwl.hh is in libpwl-dev 0.11.2-6ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
/* This is the header file of the Parma Watchdog Library.
   Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
   Copyright (C) 2010-2011 BUGSENG srl (http://bugseng.com)

This file is part of the Parma Watchdog Library (PWL).

The PWL is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

The PWL 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 General Public License
for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.

For the most up-to-date information see the Parma Polyhedra Library
site: http://www.cs.unipr.it/ppl/ . */

#ifndef PWL_pwl_hh
#define PWL_pwl_hh 1

#ifdef NDEBUG
# define PWL_SAVE_NDEBUG NDEBUG
# undef NDEBUG
#endif

// Automatically generated from PPL source file ../pwl-config.h line 1
/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  */

/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't.
   */
#define PWL_HAVE_DECL_GETENV 1

/* Define to 1 if you have the declaration of `setitimer', and to 0 if you
   don't. */
#define PWL_HAVE_DECL_SETITIMER 1

/* Define to 1 if you have the declaration of `sigaction', and to 0 if you
   don't. */
#define PWL_HAVE_DECL_SIGACTION 1

/* Define to 1 if you have the <dlfcn.h> header file. */
#define PWL_HAVE_DLFCN_H 1

/* Define to 1 if you have the <fenv.h> header file. */
#define PWL_HAVE_FENV_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define PWL_HAVE_INTTYPES_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define PWL_HAVE_MEMORY_H 1

/* Define to 1 if the system has the type `siginfo_t'. */
#define PWL_HAVE_SIGINFO_T 1

/* Define to 1 if you have the <stdint.h> header file. */
#define PWL_HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define PWL_HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define PWL_HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define PWL_HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define PWL_HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/time.h> header file. */
#define PWL_HAVE_SYS_TIME_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define PWL_HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define PWL_HAVE_UNISTD_H 1

/* Define to the sub-directory in which libtool stores uninstalled libraries.
   */
#define LT_OBJDIR ".libs/"

/* Define to the address where bug reports for this package should be sent. */
#define PWL_PACKAGE_BUGREPORT "bagnara@cs.unipr.it"

/* Define to the full name of this package. */
#define PWL_PACKAGE_NAME "the Parma Watchdog Library"

/* Define to the full name and version of this package. */
#define PWL_PACKAGE_STRING "the Parma Watchdog Library 0.8"

/* Define to the one symbol short name of this package. */
#define PWL_PACKAGE_TARNAME "pwl"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PWL_PACKAGE_VERSION "0.8"

/* Assertions are disabled when this is defined */
#define PWL_NDEBUG 1

/* Define to 1 if you have the ANSI C header files. */
#define PWL_STDC_HEADERS 1

/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define PWL_TIME_WITH_SYS_TIME 1

/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */


#if defined(PWL_NDEBUG) && !defined(NDEBUG)
# define NDEBUG PWL_NDEBUG
#endif

// Automatically generated from PPL source file ../src/Doubly_Linked_Object.types.hh line 1

#ifndef PWL_Doubly_Linked_Object_types_hh
#define PWL_Doubly_Linked_Object_types_hh 1

namespace Parma_Watchdog_Library {

class Doubly_Linked_Object;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Doubly_Linked_Object_types_hh)
// Automatically generated from PPL source file ../src/EList.types.hh line 1

#ifndef PWL_EList_types_hh
#define PWL_EList_types_hh 1

namespace Parma_Watchdog_Library {

template <typename T>
class EList;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_EList_types_hh)
// Automatically generated from PPL source file ../src/EList_Iterator.types.hh line 1

#ifndef PWL_EList_Iterator_types_hh
#define PWL_EList_Iterator_types_hh 1

namespace Parma_Watchdog_Library {

template <typename T>
class EList_Iterator;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_EList_Iterator_types_hh)
// Automatically generated from PPL source file ../src/Handler.types.hh line 1

#ifndef PWL_Handler_types_hh
#define PWL_Handler_types_hh 1

namespace Parma_Watchdog_Library {

class Handler;

template <typename Flag_Base, typename Flag>
class Handler_Flag;

class Handler_Function;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Handler_types_hh)
// Automatically generated from PPL source file ../src/Pending_Element.types.hh line 1

#ifndef PWL_Pending_Element_types_hh
#define PWL_Pending_Element_types_hh 1

namespace Parma_Watchdog_Library {

template <class Threshold>
class Pending_Element;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Pending_Element_types_hh)
// Automatically generated from PPL source file ../src/Pending_List.types.hh line 1

#ifndef PWL_Pending_List_types_hh
#define PWL_Pending_List_types_hh 1

namespace Parma_Watchdog_Library {

template <typename Traits>
class Pending_List;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Pending_List_types_hh)
// Automatically generated from PPL source file ../src/Time.types.hh line 1

#ifndef PWL_Time_types_hh
#define PWL_Time_types_hh 1

namespace Parma_Watchdog_Library {

class Time;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Time_types_hh)
// Automatically generated from PPL source file ../src/Watchdog.types.hh line 1

#ifndef PWL_Watchdog_types_hh
#define PWL_Watchdog_types_hh 1

namespace Parma_Watchdog_Library {
  class Watchdog;
  class Flag;
  class Init;
}

#endif // !defined(PWL_Watchdog_types_hh)
// Automatically generated from PPL source file ../src/Threshold_Watcher.types.hh line 1

#ifndef PWL_Threshold_Watcher_types_hh
#define PWL_Threshold_Watcher_types_hh 1

namespace Parma_Watchdog_Library {

template <typename Traits>
class Threshold_Watcher;

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Threshold_Watcher_types_hh)
// Automatically generated from PPL source file ../src/Handler.defs.hh line 1
/* Handler and derived classes' declaration.
*/

#ifndef PWL_Handler_defs_hh
#define PWL_Handler_defs_hh 1

// Automatically generated from PPL source file ../src/Handler.defs.hh line 28

//! Abstract base class for handlers of the watchdog events.
class Parma_Watchdog_Library::Handler {
public:
  //! Does the job.
  virtual void act() const = 0;

  //! Virtual destructor.
  virtual ~Handler();
};

//! A kind of Handler that installs a flag onto a flag-holder.
/*!
  The template class Handler_Flag<Flag_Base, Flag> is an handler whose
  job is to install a flag onto an <EM>holder</EM> for the flag.
  The flag is of type \p Flag and the holder is a (volatile) pointer
  to \p Flag_Base.  Installing the flag onto the holder means making
  the holder point to the flag, so that it must be possible to assign
  a value of type <CODE>Flag*</CODE> to an entity of type
  <CODE>Flag_Base*</CODE>.
  The class \p Flag must provide the method

  \code
    int priority() const
  \endcode
  returning an integer priority associated to the flag.

  The handler will install its flag onto the holder only if the holder
  is empty, namely, it is the null pointer, or if the holder holds a
  flag of strictly lower priority.
 */
template <typename Flag_Base, typename Flag>
class Parma_Watchdog_Library::Handler_Flag : virtual public Handler {
public:
  //! Constructor with a given function.
  Handler_Flag(const Flag_Base* volatile& holder, Flag& flag);

  //! Does its job: installs the flag onto the holder, if a flag with
  //! an higher priority has not already been installed.
  void act() const;

private:
  // declare holder as reference to volatile pointer to const Flag_Base
  const Flag_Base* volatile& h;
  Flag& f;
};

//! A kind of Handler calling a given function.
class Parma_Watchdog_Library::Handler_Function : virtual public Handler {
public:
  //! Constructor with a given function.
  Handler_Function(void (*function)());

  //! Does its job: calls the embedded function.
  void act() const;

private:
  //! Pointer to the embedded function.
  void (*f)();
};

// Automatically generated from PPL source file ../src/Handler.inlines.hh line 1
/* Handler and derived classes' implementation: inline functions.
*/

#ifndef PWL_Handler_inlines_hh
#define PWL_Handler_inlines_hh 1

namespace Parma_Watchdog_Library {

inline
Handler::~Handler() {
}

template <typename Flag_Base, typename Flag>
Handler_Flag<Flag_Base, Flag>::Handler_Flag(const Flag_Base* volatile& holder,
					    Flag& flag)
  : h(holder), f(flag) {
}

template <typename Flag_Base, typename Flag>
void
Handler_Flag<Flag_Base, Flag>::act() const {
  if (h == 0 || static_cast<const Flag&>(*h).priority() < f.priority())
    h = &f;
}

inline
Handler_Function::Handler_Function(void (*function)())
  : f(function) {
}

inline void
Handler_Function::act() const {
  (*f)();
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Handler_inlines_hh)
// Automatically generated from PPL source file ../src/Handler.defs.hh line 90

#endif // !defined(PWL_Handler_defs_hh)
// Automatically generated from PPL source file ../src/Time.defs.hh line 1
/* Time class declaration.
*/

#ifndef PWL_Time_defs_hh
#define PWL_Time_defs_hh 1

// Automatically generated from PPL source file ../src/Time.defs.hh line 28

namespace Parma_Watchdog_Library {

//! Returns <CODE>true</CODE> if and only if \p x and \p y are equal.
bool operator==(const Time& x, const Time& y);

//! Returns <CODE>true</CODE> if and only if \p x and \p y are different.
bool operator!=(const Time& x, const Time& y);

//! Returns <CODE>true</CODE> if and only if \p x is shorter than \p y.
bool operator<(const Time& x, const Time& y);

/*! \brief
  Returns <CODE>true</CODE> if and only if \p x is shorter than
  or equal to \p y.
*/
bool operator<=(const Time& x, const Time& y);

//! Returns <CODE>true</CODE> if and only if \p x is longer than \p y.
bool operator>(const Time& x, const Time& y);

/*! \brief
  Returns <CODE>true</CODE> if and only if \p x is longer than
  or equal to \p y.
*/
bool operator>=(const Time& x, const Time& y);

//! Returns the sum of \p x and \p y.
Time operator+(const Time& x, const Time& y);

/*! \brief
  Returns the difference of \p x and \p y or the null interval,
  if \p x is shorter than \p y.
*/
Time operator-(const Time& x, const Time& y);

} // namespace Parma_Watchdog_Library

//! A class for representing and manipulating positive time intervals.
class Parma_Watchdog_Library::Time {
public:
  //! Zero seconds.
  Time();

  //! Constructor taking a number of hundredths of a second.
  explicit Time(unsigned long hundredths_of_a_second);

  //! Constructor with seconds and microseconds.
  Time(unsigned long s, unsigned long m);

  /*! \brief
    Returns the number of whole seconds contained in the represented
    time interval.
  */
  unsigned long seconds() const;

  /*! \brief
    Returns the number of microseconds that, when added to the number
    of seconds returned by seconds(), give the represent time interval.
  */
  unsigned long microseconds() const;

  //! Adds \p y to \p *this.
  Time& operator+=(const Time& y);

  /*! \brief
    Subtracts \p y from \p *this; if \p *this is shorter than \p y,
    \p *this is set to the null interval.
  */
  Time& operator-=(const Time& y);

  //! Checks if all the invariants are satisfied.
  bool OK() const;

private:
  //! Number of seconds.
  unsigned long secs;

  //! Number of microseconds.
  unsigned long microsecs;
};

// Automatically generated from PPL source file ../src/Time.inlines.hh line 1
/* Time class implementation: inline functions.
*/

#ifndef PWL_Time_inlines_hh
#define PWL_Time_inlines_hh 1

#include <cassert>

namespace Parma_Watchdog_Library {

inline
Time::Time()
  : secs(0), microsecs(0) {
  assert(OK());
}

inline
Time::Time(unsigned long hundredths_of_a_second)
  : secs(hundredths_of_a_second / 100),
    microsecs((hundredths_of_a_second % 100) * 10000) {
  assert(OK());
}

inline
Time::Time(unsigned long s, unsigned long m)
  : secs(s),
    microsecs(m) {
  if (microsecs >= 1000000) {
    secs += microsecs / 1000000;
    microsecs %= 1000000;
  }
  assert(OK());
}

inline unsigned long
Time::seconds() const {
  return secs;
}

inline unsigned long
Time::microseconds() const {
  return microsecs;
}

inline Time&
Time::operator+=(const Time& y) {
  unsigned long r_secs = secs + y.secs;
  unsigned long r_microsecs = microsecs + y.microsecs;
  if (r_microsecs >= 1000000) {
    ++r_secs;
    r_microsecs %= 1000000;
  }
  secs = r_secs;
  microsecs = r_microsecs;
  assert(OK());
  return *this;
}

inline Time&
Time::operator-=(const Time& y) {
  long r_secs = secs - y.secs;
  long r_microsecs = microsecs - y.microsecs;
  if (r_microsecs < 0) {
    --r_secs;
    r_microsecs += 1000000;
  }
  if (r_secs < 0)
    r_secs = r_microsecs = 0;
  secs = r_secs;
  microsecs = r_microsecs;
  assert(OK());
  return *this;
}

inline Time
operator+(const Time& x, const Time& y) {
  Time z = x;
  z += y;
  return z;
}

inline Time
operator-(const Time& x, const Time& y) {
  Time z = x;
  z -= y;
  return z;
}

inline bool
operator==(const Time& x, const Time& y) {
  assert(x.OK() && y.OK());
  return x.seconds() == y.seconds() && y.microseconds() == y.microseconds();
}

inline bool
operator!=(const Time& x, const Time& y) {
  assert(x.OK() && y.OK());
  return !(x == y);
}

inline bool
operator<(const Time& x, const Time& y) {
  assert(x.OK() && y.OK());
  return x.seconds() < y.seconds()
    || (x.seconds() == y.seconds() && x.microseconds() < y.microseconds());
}

inline bool
operator<=(const Time& x, const Time& y) {
  return x < y || x == y;
}

inline bool
operator>(const Time& x, const Time& y) {
  return y < x;
}

inline bool
operator>=(const Time& x, const Time& y) {
  return y <= x;
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Time_inlines_hh)
// Automatically generated from PPL source file ../src/Time.defs.hh line 111

#endif // !defined(PWL_Time_defs_hh)
// Automatically generated from PPL source file ../src/Doubly_Linked_Object.defs.hh line 1
/* Doubly_Linked_Object class declaration.
*/

#ifndef PWL_Doubly_Linked_Object_defs_hh
#define PWL_Doubly_Linked_Object_defs_hh 1

// Automatically generated from PPL source file ../src/Doubly_Linked_Object.defs.hh line 30

//! A (base) class for doubly linked objects.
class Parma_Watchdog_Library::Doubly_Linked_Object {
public:
  //! Default constructor.
  Doubly_Linked_Object();

  //! Creates a chain element with forward link \p f and backward link \p b.
  Doubly_Linked_Object(Doubly_Linked_Object* f, Doubly_Linked_Object* b);

  //! Inserts \p y before \p *this.
  void insert_before(Doubly_Linked_Object& y);

  //! Inserts \p y after \p *this.
  void insert_after(Doubly_Linked_Object& y);

  //! Erases \p *this from the chain and returns a pointer to the next element.
  Doubly_Linked_Object* erase();

  //! Erases \p *this from the chain.
  ~Doubly_Linked_Object();

private:
  //! Forward link.
  Doubly_Linked_Object* next;

  //! Backward link.
  Doubly_Linked_Object* prev;

  template <typename T> friend class EList;
  template <typename T> friend class EList_Iterator;
};

// Automatically generated from PPL source file ../src/Doubly_Linked_Object.inlines.hh line 1
/* Doubly_Linked_Object class implementation: inline functions.
*/

#ifndef PWL_Doubly_Linked_Object_inlines_hh
#define PWL_Doubly_Linked_Object_inlines_hh 1

namespace Parma_Watchdog_Library {

inline
Doubly_Linked_Object::Doubly_Linked_Object() {
}

inline
Doubly_Linked_Object::Doubly_Linked_Object(Doubly_Linked_Object* f,
					   Doubly_Linked_Object* b)
  : next(f),
    prev(b) {
}

inline void
Doubly_Linked_Object::insert_before(Doubly_Linked_Object& y) {
  y.next = this;
  y.prev = prev;
  prev->next = &y;
  prev = &y;
}

inline void
Doubly_Linked_Object::insert_after(Doubly_Linked_Object& y) {
  y.next = next;
  y.prev = this;
  next->prev = &y;
  next = &y;
}

inline Doubly_Linked_Object*
Doubly_Linked_Object::erase() {
  next->prev = prev;
  prev->next = next;
  return next;
}

inline
Doubly_Linked_Object::~Doubly_Linked_Object() {
  erase();
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Doubly_Linked_Object_inlines_hh)
// Automatically generated from PPL source file ../src/Doubly_Linked_Object.defs.hh line 64

#endif // !defined(PWL_Doubly_Linked_Object_defs_hh)
// Automatically generated from PPL source file ../src/EList_Iterator.defs.hh line 1
/* EList_Iterator class declaration.
*/

#ifndef PWL_EList_Iterator_defs_hh
#define PWL_EList_Iterator_defs_hh 1

// Automatically generated from PPL source file ../src/EList_Iterator.defs.hh line 29

namespace Parma_Watchdog_Library {

//! Returns <CODE>true</CODE> if and only if \p x and \p y are equal.
template <typename T>
bool operator==(const EList_Iterator<T>& x, const EList_Iterator<T>& y);

//! Returns <CODE>true</CODE> if and only if \p x and \p y are different.
template <typename T>
bool operator!=(const EList_Iterator<T>& x, const EList_Iterator<T>& y);

} // namespace Parma_Watchdog_Library

//! A class providing iterators for embedded lists.
template <typename T>
class Parma_Watchdog_Library::EList_Iterator {
public:
  //! Constructs an iterator pointing to nothing.
  EList_Iterator();

  //! Constructs an iterator pointing to \p p.
  explicit EList_Iterator(Doubly_Linked_Object* p);

  //! Changes \p *this so that it points to \p p.
  EList_Iterator& operator=(Doubly_Linked_Object* p);

  //! Indirect member selector.
  T* operator->();

  //! Dereference operator.
  T& operator*();

  //! Preincrement operator.
  EList_Iterator& operator++();

  //! Postincrement operator.
  EList_Iterator operator++(int);

  //! Predecrement operator.
  EList_Iterator& operator--();

  //! Postdecrement operator.
  EList_Iterator operator--(int);

private:
  //! Embedded pointer.
  Doubly_Linked_Object* ptr;

  friend bool operator==<T>(const EList_Iterator& x, const EList_Iterator& y);

  friend bool operator!=<T>(const EList_Iterator& x, const EList_Iterator& y);
};

// Automatically generated from PPL source file ../src/EList_Iterator.inlines.hh line 1
/* EList_Iterator class implementation: inline functions.
*/

#ifndef PWL_EList_Iterator_inlines_hh
#define PWL_EList_Iterator_inlines_hh 1

// Automatically generated from PPL source file ../src/EList_Iterator.inlines.hh line 28

namespace Parma_Watchdog_Library {

template <typename T>
inline
EList_Iterator<T>::EList_Iterator() {
}

template <typename T>
inline
EList_Iterator<T>::EList_Iterator(Doubly_Linked_Object* p)
  : ptr(p) {
}

template <typename T>
inline EList_Iterator<T>&
EList_Iterator<T>::operator=(Doubly_Linked_Object* p) {
  ptr = p;
  return *this;
}

template <typename T>
inline T*
EList_Iterator<T>::operator->() {
  return static_cast<T*>(ptr);
}

template <typename T>
inline T&
EList_Iterator<T>::operator*() {
  return *operator->();
}

template <typename T>
inline EList_Iterator<T>&
EList_Iterator<T>::operator++() {
  ptr = ptr->next;
  return *this;
}

template <typename T>
inline EList_Iterator<T>
EList_Iterator<T>::operator++(int) {
  EList_Iterator tmp = *this;
  ++*this;
  return tmp;
}

template <typename T>
inline EList_Iterator<T>&
EList_Iterator<T>::operator--() {
  ptr = ptr->prev;
  return *this;
}

template <typename T>
inline EList_Iterator<T>
EList_Iterator<T>::operator--(int) {
  EList_Iterator tmp = *this;
  --*this;
  return tmp;
}

template <typename T>
inline bool
operator==(const EList_Iterator<T>& x, const EList_Iterator<T>& y) {
  return x.ptr == y.ptr;
}

template <typename T>
inline bool
operator!=(const EList_Iterator<T>& x, const EList_Iterator<T>& y) {
  return x.ptr != y.ptr;
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_EList_Iterator_inlines_hh)
// Automatically generated from PPL source file ../src/EList_Iterator.defs.hh line 83

#endif // !defined(PWL_EList_Iterator_defs_hh)
// Automatically generated from PPL source file ../src/EList.defs.hh line 1
/* EList class declaration.
*/

#ifndef PWL_EList_defs_hh
#define PWL_EList_defs_hh 1

// Automatically generated from PPL source file ../src/EList.defs.hh line 30

/*! \brief
  A simple kind of embedded list (i.e., a doubly linked objects
  where the links are embedded in the objects themselves).
*/
template <typename T>
class Parma_Watchdog_Library::EList
  : private Parma_Watchdog_Library::Doubly_Linked_Object {
public:
  //! A const iterator to traverse the list.
  typedef EList_Iterator<const T> Const_Iterator;

  //! A non-const iterator to traverse the list.
  typedef EList_Iterator<T> Iterator;

  //! Constructs an empty list.
  EList();

  //! Destructs the list and all the elements in it.
  ~EList();

  //! Pushes \p obj to the front of the list.
  void push_front(T& obj);

  //! Pushes \p obj to the back of the list.
  void push_back(T& obj);

  /*! \brief
    Inserts \p obj just before \p position and returns an iterator
    that points to the inserted object.
  */
  Iterator insert(Iterator position, T& obj);

  /*! \brief
    Removes the element pointed to by \p position, returning
    an iterator pointing to the next element, if any, or end(), otherwise.
  */
  Iterator erase(Iterator position);

  //! Returns <CODE>true</CODE> if and only if the list is empty.
  bool empty() const;

  //! Returns an iterator pointing to the beginning of the list.
  Iterator begin();

  //! Returns an iterator pointing one past the last element in the list.
  Iterator end();

  //! Returns a const iterator pointing to the beginning of the list.
  Const_Iterator begin() const;

  //! Returns a const iterator pointing one past the last element in the list.
  Const_Iterator end() const;

  //! Checks if all the invariants are satisfied.
  bool OK() const;
};

// Automatically generated from PPL source file ../src/EList.inlines.hh line 1
/* EList class implementation: inline functions.
*/

#ifndef PWL_EList_inlines_hh
#define PWL_EList_inlines_hh 1

#include <cassert>

namespace Parma_Watchdog_Library {

template <typename T>
inline
EList<T>::EList()
  : Doubly_Linked_Object(this, this) {
}

template <typename T>
inline void
EList<T>::push_front(T& obj) {
  next->insert_before(obj);
}

template <typename T>
inline void
EList<T>::push_back(T& obj) {
  prev->insert_after(obj);
}

template <typename T>
inline typename EList<T>::Iterator
EList<T>::insert(Iterator position, T& obj) {
  position->insert_before(obj);
  return Iterator(&obj);
}

template <typename T>
inline typename EList<T>::Iterator
EList<T>::begin() {
  return Iterator(next);
}

template <typename T>
inline typename EList<T>::Iterator
EList<T>::end() {
  return Iterator(this);
}

template <typename T>
inline typename EList<T>::Const_Iterator
EList<T>::begin() const {
  return Const_Iterator(next);
}

template <typename T>
inline typename EList<T>::Const_Iterator
EList<T>::end() const {
  return Const_Iterator(const_cast<EList<T>*>(this));
}

template <typename T>
inline bool
EList<T>::empty() const {
  return begin() == end();
}

template <typename T>
inline typename EList<T>::Iterator
EList<T>::erase(Iterator position) {
  assert(!empty());
  return Iterator(position->erase());
}

template <typename T>
inline
EList<T>::~EList() {
  // Erase and deallocate all the elements.
  for (Iterator i = begin(), lend = end(), next; i != lend; i = next) {
    next = erase(i);
    delete &*i;
  }
}

template <typename T>
inline bool
EList<T>::OK() const {
  for (Const_Iterator i = begin(), lend = end(); i != lend; ++i)
    if (!i->OK())
      return false;

  return true;
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_EList_inlines_hh)
// Automatically generated from PPL source file ../src/EList.defs.hh line 89

#endif // !defined(PWL_EList_defs_hh)
// Automatically generated from PPL source file ../src/Pending_Element.defs.hh line 1
/* Pending_Element class declaration.
*/

#ifndef PWL_Pending_Element_defs_hh
#define PWL_Pending_Element_defs_hh 1

// Automatically generated from PPL source file ../src/Pending_Element.defs.hh line 30

//! A class for pending watchdog events with embedded links.
/*!
  Each pending watchdog event is characterized by a deadline (a positive
  time interval), an associated handler that will be invoked upon event
  expiration, and a Boolean flag that indicates whether the event has already
  expired or not.
*/
template <typename Threshold>
class Parma_Watchdog_Library::Pending_Element : public Doubly_Linked_Object {
public:
  //! Constructs an element with the given attributes.
  Pending_Element(const Threshold& deadline,
		  const Handler& handler,
		  bool& expired_flag);

  //! Modifies \p *this so that it has the given attributes.
  void assign(const Threshold& deadline,
	      const Handler& handler,
	      bool& expired_flag);

  //! Returns the deadline of the event.
  const Threshold& deadline() const;

  //! Returns the handler associated to the event.
  const Handler& handler() const;

  //! Returns a reference to the "event-expired" flag.
  bool& expired_flag() const;

  //! Checks if all the invariants are satisfied.
  bool OK() const;

private:
  //! The deadline of the event.
  Threshold d;

  //! A pointer to the handler associated to the event.
  const Handler* p_h;

  //! A pointer to a flag saying whether the event has already expired or not.
  bool* p_f;
};

// Automatically generated from PPL source file ../src/Pending_Element.inlines.hh line 1
/* Pending_Element class implementation: inline functions.
*/

#ifndef PWL_Pending_Element_inlines_hh
#define PWL_Pending_Element_inlines_hh 1

#include <cassert>

namespace Parma_Watchdog_Library {

template <typename Threshold>
inline bool
Pending_Element<Threshold>::OK() const {
  return true;
}

template <typename Threshold>
inline
Pending_Element<Threshold>::Pending_Element(const Threshold& deadline,
					    const Handler& handler,
					    bool& expired_flag)
  : d(deadline), p_h(&handler), p_f(&expired_flag) {
  assert(OK());
}

template <typename Threshold>
inline void
Pending_Element<Threshold>::assign(const Threshold& deadline,
				   const Handler& handler,
				   bool& expired_flag) {
  d = deadline;
  p_h = &handler;
  p_f = &expired_flag;
  assert(OK());
}

template <typename Threshold>
inline const Threshold&
Pending_Element<Threshold>::deadline() const {
  return d;
}

template <typename Threshold>
inline const Handler&
Pending_Element<Threshold>::handler() const {
  return *p_h;
}

template <typename Threshold>
inline bool&
Pending_Element<Threshold>::expired_flag() const {
  return *p_f;
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Pending_Element_inlines_hh)
// Automatically generated from PPL source file ../src/Pending_Element.defs.hh line 75

#endif // !defined(PWL_Pending_Element_defs_hh)
// Automatically generated from PPL source file ../src/Pending_List.defs.hh line 1
/* Pending_List class declaration.
*/

#ifndef PWL_Pending_List_defs_hh
#define PWL_Pending_List_defs_hh 1

// Automatically generated from PPL source file ../src/Pending_List.defs.hh line 31

//! An ordered list for recording pending watchdog events.
template <typename Traits>
class Parma_Watchdog_Library::Pending_List {
public:
  //! A non-const iterator to traverse the list.
  typedef typename EList<Pending_Element<typename Traits::Threshold> >::Iterator Iterator;

  //! A const iterator to traverse the list.
  typedef typename EList<Pending_Element<typename Traits::Threshold> >::Const_Iterator Const_Iterator;

  //! Constructs an empty list.
  Pending_List();

  //! Destructor.
  ~Pending_List();

  //! Inserts a new Pending_Element object with the given attributes.
  Iterator insert(const typename Traits::Threshold& deadline,
		  const Handler& handler,
		  bool& expired_flag);

  /*! \brief
    Removes the element pointed to by \p position, returning
    an iterator pointing to the next element, if any, or end(), otherwise.
  */
  Iterator erase(Iterator position);

  //! Returns <CODE>true</CODE> if and only if the list is empty.
  bool empty() const;

  //! Returns an iterator pointing to the beginning of the list.
  Iterator begin();

  //! Returns an iterator pointing one past the last element in the list.
  Iterator end();

  //! Checks if all the invariants are satisfied.
  bool OK() const;

private:
  EList<Pending_Element<typename Traits::Threshold> > active_list;
  EList<Pending_Element<typename Traits::Threshold> > free_list;
};

// Automatically generated from PPL source file ../src/Pending_List.inlines.hh line 1
/* Pending_List class implementation: inline functions.
*/

#ifndef PWL_Pending_List_inlines_hh
#define PWL_Pending_List_inlines_hh 1

#include <cassert>

namespace Parma_Watchdog_Library {

template <typename Traits>
inline
Pending_List<Traits>::Pending_List()
  : active_list(),
    free_list() {
  assert(OK());
}

template <typename Traits>
inline
Pending_List<Traits>::~Pending_List() {
}

template <typename Traits>
inline typename Pending_List<Traits>::Iterator
Pending_List<Traits>::begin() {
  return active_list.begin();
}

template <typename Traits>
inline typename Pending_List<Traits>::Iterator
Pending_List<Traits>::end() {
  return active_list.end();
}

template <typename Traits>
inline bool
Pending_List<Traits>::empty() const {
  return active_list.empty();
}

template <typename Traits>
inline typename Pending_List<Traits>::Iterator
Pending_List<Traits>::erase(Iterator position) {
  assert(!empty());
  Iterator next = active_list.erase(position);
  free_list.push_back(*position);
  assert(OK());
  return next;
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Pending_List_inlines_hh)
// Automatically generated from PPL source file ../src/Pending_List.templates.hh line 1
/* Pending_List class implementation.
*/

#ifndef PWL_Pending_List_templates_hh
#define PWL_Pending_List_templates_hh 1

#include <iostream>

namespace Parma_Watchdog_Library {

template <typename Traits>
typename Pending_List<Traits>::Iterator
Pending_List<Traits>::insert(const typename Traits::Threshold& deadline,
			     const Handler& handler,
			     bool& expired_flag) {
  Iterator position = active_list.begin();
  for (Iterator active_list_end = active_list.end();
       position != active_list_end && Traits::less_than(position->deadline(), deadline);
       ++position)
    ;
  Iterator ppe;
  // Only allocate a new element if the free list is empty.
  if (free_list.empty())
    ppe = new Pending_Element<typename Traits::Threshold>(deadline, handler, expired_flag);
  else {
    ppe = free_list.begin();
    free_list.erase(ppe);
    ppe->assign(deadline, handler, expired_flag);
  }
  Iterator r = active_list.insert(position, *ppe);
  assert(OK());
  return r;
}

template <typename Traits>
bool
Pending_List<Traits>::OK() const {
  if (!active_list.OK())
    return false;

  if (!free_list.OK())
    return false;

  const typename Traits::Threshold* old;
  Const_Iterator i = active_list.begin();
  old = &i->deadline();
  ++i;
  for (Const_Iterator active_list_end = active_list.end(); i != active_list_end; ++i) {
    const typename Traits::Threshold& t = i->deadline();
    if (Traits::less_than(t, *old)) {
#ifndef NDEBUG
      std::cerr << "The active list is not sorted!"
		<< std::endl;
#endif
      return false;
    }
    old = &t;
  }
  return true;
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Pending_List_templates_hh)
// Automatically generated from PPL source file ../src/Pending_List.defs.hh line 78

#endif // !defined(PWL_Pending_List_defs_hh)
// Automatically generated from PPL source file ../src/Watchdog.defs.hh line 1
/* Watchdog and associated classes' declaration and inline functions.
*/

#ifndef PWL_Watchdog_defs_hh
#define PWL_Watchdog_defs_hh 1

// Automatically generated from PPL source file ../src/Watchdog.defs.hh line 31
#include <cassert>
#include <functional>

#ifdef PWL_HAVE_SYS_TIME_H
# include <sys/time.h>
#endif

namespace Parma_Watchdog_Library {

// Set linkage now to declare it friend later.
extern "C" void PWL_handle_timeout(int signum);

struct Watchdog_Traits {
  typedef Time Threshold;
  static bool less_than(const Threshold& a, const Threshold& b) {
    return a < b;
  }
};

//! A watchdog timer.
class Watchdog {
public:
  template <typename Flag_Base, typename Flag>
  Watchdog(unsigned int units, const Flag_Base* volatile& holder, Flag& flag);

  /*! \brief
    Constructor: if not reset, the watchdog will trigger after \p units
    hundreths of seconds, invoking handler \p function.
  */
  Watchdog(unsigned int units, void (*function)());

  //! Destructor.
  ~Watchdog();

#if PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION

private:
  typedef Pending_List<Watchdog_Traits> WD_Pending_List;
  friend class Init;

  //! Static class initialization.
  static void initialize();
  //! Static class finalization.
  static void finalize();

  //! Whether or not this watchdog has expired.
  bool expired;

  const Handler& handler;
  WD_Pending_List::Iterator pending_position;

  // Private and not implemented: copy construction is not allowed.
  Watchdog(const Watchdog&);
  // Private and not implemented: copy assignment is not allowed.
  Watchdog& operator=(const Watchdog&);

  // Pass this to getitimer().
  static itimerval current_timer_status;

  //! Reads the timer value into \p time.
  static void get_timer(Time& time);

  // Pass this to setitimer().
  static itimerval signal_once;

  // Last time value we set the timer to.
  static Time last_time_requested;

  //! Sets the timer value to \p time.
  static void set_timer(const Time& time);

  //! Stops the timer.
  static void stop_timer();

  //! Quick reschedule to avoid race conditions.
  static void reschedule();

  // Used by the above.
  static Time reschedule_time;

  // Records the time elapsed since last fresh start.
  static Time time_so_far;

  //! The ordered queue of pending watchdog events.
  static WD_Pending_List pending;

  //! The actual signal handler.
  static void handle_timeout(int);

  //! Handles the addition of a new watchdog event.
  static WD_Pending_List::Iterator
  new_watchdog_event(unsigned int units,
                     const Handler& handler,
                     bool& expired_flag);

  //! Handles the removal of the watchdog event referred by \p position.
  void remove_watchdog_event(WD_Pending_List::Iterator position);

  //! Whether the alarm clock is running.
  static volatile bool alarm_clock_running;

  //! Whether we are changing data that is also changed by the signal handler.
  static volatile bool in_critical_section;

  friend void PWL_handle_timeout(int signum);

#endif // PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION
};

#if PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION

class Init {
private:
  //! Count the number of objects created.
  static unsigned int count;

public:
  //! Initializes the PWL.
  Init();

  //! Finalizes the PWL.
  ~Init();
};

#endif // PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION

} // namespace Parma_Watchdog_Library

// Automatically generated from PPL source file ../src/Watchdog.inlines.hh line 1
/* Watchdog and associated classes' implementation: inline functions.
*/

#ifndef PWL_Watchdog_inlines_hh
#define PWL_Watchdog_inlines_hh 1

#include <stdexcept>

// Automatically generated from PPL source file ../src/Watchdog.inlines.hh line 30

namespace Parma_Watchdog_Library {

#if PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION

template <typename Flag_Base, typename Flag>
Watchdog::Watchdog(unsigned int units,
		   const Flag_Base* volatile& holder,
                   Flag& flag)
  : expired(false),
    handler(*new Handler_Flag<Flag_Base, Flag>(holder, flag)) {
  if (units == 0)
    throw std::invalid_argument("Watchdog constructor called with a"
				" non-positive number of time units");
  in_critical_section = true;
  pending_position = new_watchdog_event(units, handler, expired);
  in_critical_section = false;
}

inline
Watchdog::Watchdog(unsigned int units, void (*function)())
  : expired(false), handler(*new Handler_Function(function)) {
  if (units == 0)
    throw std::invalid_argument("Watchdog constructor called with a"
				" non-positive number of time units");
  in_critical_section = true;
  pending_position = new_watchdog_event(units, handler, expired);
  in_critical_section = false;
}

inline
Watchdog::~Watchdog() {
  if (!expired) {
    in_critical_section = true;
    remove_watchdog_event(pending_position);
    in_critical_section = false;
  }
  delete &handler;
}

inline void
Watchdog::reschedule() {
  set_timer(reschedule_time);
}

inline
Init::Init() {
  // Only when the first Init object is constructed...
  if (count++ == 0) {
    // ... the library is initialized.
    Watchdog::initialize();
  }
}

inline
Init::~Init() {
  // Only when the last Init object is destroyed...
  if (--count == 0) {
    // ... the library is finalized.
    Watchdog::finalize();
  }
}

#else // !PWL_HAVE_DECL_SETITIMER !! !PWL_HAVE_DECL_SIGACTION

template <typename Flag_Base, typename Flag>
Watchdog::Watchdog(unsigned int /* units */,
		   const Flag_Base* volatile& /* holder */,
                   Flag& /* flag */) {
  throw std::logic_error("PWL::Watchdog objects not supported:"
                         " system does not provide setitimer()");
}

inline
Watchdog::Watchdog(unsigned int /* units */, void (* /* function */)()) {
  throw std::logic_error("PWL::Watchdog objects not supported:"
                         " system does not provide setitimer()");
}

inline
Watchdog::~Watchdog() {
}

#endif // !PWL_HAVE_DECL_SETITIMER !! !PWL_HAVE_DECL_SIGACTION

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Watchdog_inlines_hh)
// Automatically generated from PPL source file ../src/Watchdog.defs.hh line 160

#if PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION

namespace {

Parma_Watchdog_Library::Init Parma_Watchdog_Library_initializer;

} // namespace

#endif // PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION

#endif // !defined(PWL_Watchdog_defs_hh)

// Automatically generated from PPL source file ../src/Threshold_Watcher.defs.hh line 1
/* Threshold_Watcher and associated classes' declaration and inline functions.
*/

#ifndef PWL_Threshold_Watcher_defs_hh
#define PWL_Threshold_Watcher_defs_hh 1

// Automatically generated from PPL source file ../src/Threshold_Watcher.defs.hh line 30
#include <cassert>

/*! \brief
  A class of watchdogs controlling the exceeding of a threshold.

  \tparam Traits
  A class to set data types and functions for the threshold handling.
  See \c Parma_Polyhedra_Library::Weightwatch_Traits for an example.
*/
template <typename Traits>
class Parma_Watchdog_Library::Threshold_Watcher {
public:
  template <typename Flag_Base, typename Flag>
  Threshold_Watcher(const typename Traits::Delta& delta,
                    const Flag_Base* volatile& holder,
                    Flag& flag);

  Threshold_Watcher(const typename Traits::Delta& delta,
                    void (*function)());

  ~Threshold_Watcher();

private:
  typedef Pending_List<Traits> TW_Pending_List;

  bool expired;
  const Handler& handler;
  typename TW_Pending_List::Iterator pending_position;

  // Just to prevent their use.
  Threshold_Watcher(const Threshold_Watcher&);
  Threshold_Watcher& operator=(const Threshold_Watcher&);

  struct Initialize {
    //! The ordered queue of pending thresholds.
    TW_Pending_List pending;
  };
  static Initialize init;

  // Handle the addition of a new threshold.
  static typename TW_Pending_List::Iterator
  add_threshold(typename Traits::Threshold threshold,
		const Handler& handler,
		bool& expired_flag);

  // Handle the removal of a threshold.
  static typename TW_Pending_List::Iterator
  remove_threshold(typename TW_Pending_List::Iterator position);

  //! Check threshold reaching.
  static void check();

}; // class Parma_Watchdog_Library::Threshold_Watcher


// Templatic initialization of static data member.
template <typename Traits>
typename Parma_Watchdog_Library::Threshold_Watcher<Traits>::Initialize
Parma_Watchdog_Library::Threshold_Watcher<Traits>::init;

// Automatically generated from PPL source file ../src/Threshold_Watcher.inlines.hh line 1
/* Threshold_Watcher and associated classes' implementation: inline functions.
*/

#ifndef PWL_Threshold_Watcher_inlines_hh
#define PWL_Threshold_Watcher_inlines_hh 1

#include <stdexcept>

// Automatically generated from PPL source file ../src/Threshold_Watcher.inlines.hh line 30

namespace Parma_Watchdog_Library {

template <typename Traits>
template <typename Flag_Base, typename Flag>
Threshold_Watcher<Traits>::Threshold_Watcher(const typename Traits::Delta& delta, const Flag_Base* volatile& holder, Flag& flag)
  : expired(false),
    handler(*new Handler_Flag<Flag_Base, Flag>(holder, flag)) {
  typename Traits::Threshold threshold;
  Traits::from_delta(threshold, delta);
  if (!Traits::less_than(Traits::get(), threshold))
    throw std::invalid_argument("Threshold_Watcher constructor called with a"
				" threshold already reached");
  pending_position = add_threshold(threshold, handler, expired);
}

template <typename Traits>
inline
Threshold_Watcher<Traits>::Threshold_Watcher(const typename Traits::Delta& delta, void (*function)())
  : expired(false), handler(*new Handler_Function(function)) {
  typename Traits::Threshold threshold;
  Traits::from_delta(threshold, delta);
  if (!Traits::less_than(Traits::get(), threshold))
    throw std::invalid_argument("Threshold_Watcher constructor called with a"
				" threshold already reached");
  pending_position = add_threshold(threshold, handler, expired);
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Threshold_Watcher_inlines_hh)
// Automatically generated from PPL source file ../src/Threshold_Watcher.templates.hh line 1
/* Threshold_Watcher and associated classes'.
*/

#ifndef PWL_Threshold_Watcher_templates_hh
#define PWL_Threshold_Watcher_templates_hh 1

namespace Parma_Watchdog_Library {

template <typename Traits>
typename Threshold_Watcher<Traits>::TW_Pending_List::Iterator
Threshold_Watcher<Traits>::add_threshold(typename Traits::Threshold threshold,
                                         const Handler& handler,
                                         bool& expired_flag) {
  Traits::check_function = Threshold_Watcher::check;
  return init.pending.insert(threshold, handler, expired_flag);
}

template <typename Traits>
typename Threshold_Watcher<Traits>::TW_Pending_List::Iterator
Threshold_Watcher<Traits>
::remove_threshold(typename TW_Pending_List::Iterator position) {
  typename TW_Pending_List::Iterator i = init.pending.erase(position);
  if (init.pending.empty())
    Traits::check_function = 0;
  return i;
}

template <typename Traits>
Threshold_Watcher<Traits>::~Threshold_Watcher() {
  if (!expired)
    remove_threshold(pending_position);
  delete &handler;
}

template <typename Traits>
void
Threshold_Watcher<Traits>::check() {
  typename TW_Pending_List::Iterator i = init.pending.begin();
  assert(i != init.pending.end());
  const typename Traits::Threshold& current = Traits::get();
  while (!Traits::less_than(current, i->deadline())) {
    i->handler().act();
    i->expired_flag() = true;
    i = remove_threshold(i);
    if (i == init.pending.end())
      break;
  }
}

} // namespace Parma_Watchdog_Library

#endif // !defined(PWL_Threshold_Watcher_templates_hh)
// Automatically generated from PPL source file ../src/Threshold_Watcher.defs.hh line 92

#endif // !defined(PWL_Threshold_Watcher_defs_hh)


//! Defined to 1 if PWL::Watchdog objects are supported, to 0 otherwise.
#define PWL_WATCHDOG_OBJECTS_ARE_SUPPORTED \
  (PWL_HAVE_DECL_SETITIMER && PWL_HAVE_DECL_SIGACTION)

#ifdef PWL_SAVE_NDEBUG
# ifndef NDEBUG
#  define NDEBUG PWL_SAVE_NDEBUG
# endif
# undef PWL_SAVE_NDEBUG
#else
# ifdef NDEBUG
#  undef NDEBUG
# endif
#endif
// Must include <cassert> again in order to make the latest changes to
// NDEBUG effective.
#include <cassert>

#endif