|
35 | 35 | /* For chroot(), which is not POSIX. */
|
36 | 36 | #define _DEFAULT_SOURCE
|
37 | 37 |
|
38 |
| -#include <sys/types.h> |
39 |
| -#include <sys/wait.h> |
40 |
| -#include <sys/param.h> |
| 38 | +#include <algorithm> |
| 39 | +#include <cerrno> |
| 40 | +#include <csignal> |
| 41 | +#include <climits> |
| 42 | +#include <cmath> |
| 43 | +#include <cstdio> |
| 44 | +#include <cstdlib> |
| 45 | +#include <cstring> |
| 46 | +#include <ctime> |
| 47 | +#include <fcntl.h> |
| 48 | +#include <fnmatch.h> |
| 49 | +#include <getopt.h> |
| 50 | +#include <grp.h> |
| 51 | +#include <inttypes.h> |
| 52 | +#include <limits.h> |
| 53 | +#include <pwd.h> |
| 54 | +#include <regex.h> |
| 55 | +#include <sched.h> |
| 56 | +#include <signal.h> |
| 57 | +#include <stdarg.h> |
| 58 | +#include <stdio.h> |
| 59 | +#include <stdlib.h> |
| 60 | +#include <string.h> |
| 61 | +#include <sys/resource.h> |
41 | 62 | #include <sys/select.h>
|
42 | 63 | #include <sys/stat.h>
|
| 64 | +#include <sys/sysinfo.h> |
43 | 65 | #include <sys/time.h>
|
44 | 66 | #include <sys/times.h>
|
45 |
| -#include <sys/resource.h> |
46 | 67 | #include <sys/types.h>
|
47 |
| -#include <errno.h> |
48 |
| -#include <fcntl.h> |
49 |
| -#include <signal.h> |
50 |
| -#include <stdlib.h> |
| 68 | +#include <sys/wait.h> |
| 69 | +#include <sys/param.h> |
51 | 70 | #include <unistd.h>
|
52 |
| -#include <string.h> |
53 |
| -#include <stdarg.h> |
54 |
| -#include <stdio.h> |
55 |
| -#include <getopt.h> |
56 |
| -#include <fnmatch.h> |
57 |
| -#include <regex.h> |
58 |
| -#include <pwd.h> |
59 |
| -#include <grp.h> |
60 |
| -#include <time.h> |
61 |
| -#include <math.h> |
62 |
| -#include <limits.h> |
63 |
| -#include <inttypes.h> |
64 | 71 | #include <libcgroup.h>
|
65 |
| -#include <sched.h> |
66 |
| -#include <sys/sysinfo.h> |
67 | 72 |
|
68 | 73 | #define PROGRAM "runguard"
|
69 | 74 | #define VERSION DOMJUDGE_VERSION "/" REVISION
|
70 | 75 |
|
71 |
| -#define max(x,y) ((x) > (y) ? (x) : (y)) |
72 |
| -#define min(x,y) ((x) < (y) ? (x) : (y)) |
73 |
| - |
74 | 76 | /* Array indices for input/output file descriptors as used by pipe() */
|
75 | 77 | #define PIPE_IN 1
|
76 | 78 | #define PIPE_OUT 0
|
77 | 79 |
|
78 |
| -#define BUF_SIZE 4*1024 |
| 80 | +const size_t BUF_SIZE = 4*1024; |
79 | 81 |
|
80 | 82 | /* Types of time for writing to file. */
|
81 | 83 | #define WALL_TIME_TYPE 0
|
@@ -901,7 +903,7 @@ void pump_pipes(fd_set* readfds, size_t data_read[], size_t data_passed[])
|
901 | 903 | /* Otherwise copy the output to a file */
|
902 | 904 | to_read = BUF_SIZE;
|
903 | 905 | if (limit_streamsize) {
|
904 |
| - to_read = min(BUF_SIZE, streamsize-data_passed[i]); |
| 906 | + to_read = std::min(BUF_SIZE, streamsize-data_passed[i]); |
905 | 907 | }
|
906 | 908 |
|
907 | 909 | if ( use_splice ) {
|
@@ -1359,7 +1361,7 @@ int main(int argc, char **argv)
|
1359 | 1361 | for(i=1; i<=2; i++) {
|
1360 | 1362 | if ( child_pipefd[i][PIPE_OUT]>=0 ) {
|
1361 | 1363 | FD_SET(child_pipefd[i][PIPE_OUT],&readfds);
|
1362 |
| - nfds = max(nfds,child_pipefd[i][PIPE_OUT]); |
| 1364 | + nfds = std::max(nfds,child_pipefd[i][PIPE_OUT]); |
1363 | 1365 | }
|
1364 | 1366 | }
|
1365 | 1367 |
|
|
0 commit comments