Commit | Line | Data |
---|---|---|
c4ccbbf9 MW |
1 | /* -*-c-*- |
2 | * | |
3 | * Example test program | |
4 | * | |
5 | * (c) 2024 Straylight/Edgeware | |
6 | */ | |
7 | ||
8 | /*----- Licensing notice --------------------------------------------------* | |
9 | * | |
10 | * This file is part of the mLib utilities library. | |
11 | * | |
12 | * mLib is free software: you can redistribute it and/or modify it under | |
13 | * the terms of the GNU Library General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or (at | |
15 | * your option) any later version. | |
16 | * | |
17 | * mLib is distributed in the hope that it will be useful, but WITHOUT | |
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | |
20 | * License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Library General Public | |
23 | * License along with mLib. If not, write to the Free Software | |
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
25 | * USA. | |
26 | */ | |
27 | ||
28 | #ifndef MLIB_EXAMPLE_H | |
29 | #define MLIB_EXAMPLE_H | |
30 | ||
31 | #ifdef __cplusplus | |
32 | extern "C" { | |
33 | #endif | |
34 | ||
35 | /*----- Header files ------------------------------------------------------*/ | |
36 | ||
289651a7 | 37 | #include <limits.h> |
c4ccbbf9 MW |
38 | #include <stddef.h> |
39 | ||
40 | /*----- Functions provided ------------------------------------------------*/ | |
41 | ||
42 | extern int add(int /*x*/, int /*y*/); | |
43 | /* Return the sum X + Y. */ | |
44 | ||
45 | extern int greet(char */*buf*/, size_t /*sz*/, const char */*name*/); | |
46 | /* Generate a personalized greeting, mentioning NAME. The greeting is | |
47 | * written to the output buffer BUF, which has space for SZ characters. | |
48 | * Return zero on success, or -1 on error. | |
49 | */ | |
50 | ||
289651a7 MW |
51 | extern unsigned long recfib(unsigned /*n*/); |
52 | /* Stupid but traditional recursive Fibonacci. */ | |
53 | ||
54 | extern unsigned long iterfib(unsigned /*n*/); | |
55 | /* Slightly less stupid but still traditional iterative Fibonacci. */ | |
56 | ||
57 | extern unsigned long expfib(unsigned /*n*/); | |
58 | /* Sadly nontraditional intelligent Fibonacci. */ | |
59 | ||
60 | #define RECFIBLIMIT 40 /* too slow beyond this */ | |
61 | #if (ULONG_MAX/65536 >> 16) >= 0xffffffff | |
62 | # define FIBLIMIT 94 /* F_94 = 19740274219868223167 > 2^64 */ | |
63 | #else | |
64 | # define FIBLIMIT 48 /* F_48 = 4807526976 > 2^32 */ | |
65 | #endif | |
66 | ||
c4ccbbf9 MW |
67 | /*----- That's all, folks -------------------------------------------------*/ |
68 | ||
69 | #ifdef __cplusplus | |
70 | } | |
71 | #endif | |
72 | ||
73 | #endif |