Skip to content

Commit c8ef99f

Browse files
committed
More C++ stuff.
1 parent 99a4606 commit c8ef99f

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

judge/runguard.cc

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,49 @@
3535
/* For chroot(), which is not POSIX. */
3636
#define _DEFAULT_SOURCE
3737

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>
4162
#include <sys/select.h>
4263
#include <sys/stat.h>
64+
#include <sys/sysinfo.h>
4365
#include <sys/time.h>
4466
#include <sys/times.h>
45-
#include <sys/resource.h>
4667
#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>
5170
#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>
6471
#include <libcgroup.h>
65-
#include <sched.h>
66-
#include <sys/sysinfo.h>
6772

6873
#define PROGRAM "runguard"
6974
#define VERSION DOMJUDGE_VERSION "/" REVISION
7075

71-
#define max(x,y) ((x) > (y) ? (x) : (y))
72-
#define min(x,y) ((x) < (y) ? (x) : (y))
73-
7476
/* Array indices for input/output file descriptors as used by pipe() */
7577
#define PIPE_IN 1
7678
#define PIPE_OUT 0
7779

78-
#define BUF_SIZE 4*1024
80+
const size_t BUF_SIZE = 4*1024;
7981

8082
/* Types of time for writing to file. */
8183
#define WALL_TIME_TYPE 0
@@ -901,7 +903,7 @@ void pump_pipes(fd_set* readfds, size_t data_read[], size_t data_passed[])
901903
/* Otherwise copy the output to a file */
902904
to_read = BUF_SIZE;
903905
if (limit_streamsize) {
904-
to_read = min(BUF_SIZE, streamsize-data_passed[i]);
906+
to_read = std::min(BUF_SIZE, streamsize-data_passed[i]);
905907
}
906908

907909
if ( use_splice ) {
@@ -1359,7 +1361,7 @@ int main(int argc, char **argv)
13591361
for(i=1; i<=2; i++) {
13601362
if ( child_pipefd[i][PIPE_OUT]>=0 ) {
13611363
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]);
13631365
}
13641366
}
13651367

0 commit comments

Comments
 (0)