polish gcc error

This commit is contained in:
Dun Liang 2021-04-09 12:49:14 +08:00
parent 8243ebc5b5
commit e37dd420d9
3 changed files with 12 additions and 5 deletions

View File

@ -8,7 +8,7 @@
# This file is subject to the terms and conditions defined in
# file 'LICENSE.txt', which is part of this source code package.
# ***************************************************************
__version__ = '1.2.2.58'
__version__ = '1.2.2.59'
from . import lock
with lock.lock_scope():
ori_int = int

View File

@ -166,7 +166,7 @@ inline JK& operator<<(JK& jk, int64 c) {
return jk << JK::hex(c);
}
inline JK& operator<<(JK& jk, long long c) {
inline JK& operator<<(JK& jk, long long int c) {
return jk << (int64)c;
}

View File

@ -308,16 +308,23 @@ int system_popen(const char* cmd) {
cmd2 += " 2>&1 ";
FILE *ptr = popen(cmd2.c_str(), "r");
if (!ptr) return -1;
int64 len=0;
while (fgets(buf, BUFSIZ, ptr) != NULL) {
len += strlen(buf);
puts(buf);
}
return pclose(ptr);
auto ret = pclose(ptr);
if (len<10 && ret) {
// maybe overcommit
return -1;
}
return ret;
}
void system_with_check(const char* cmd) {
auto ret = system_popen(cmd);
CHECK(ret>=0 && ret<256) << "Run cmd failed:" << cmd <<
"\nreturn -1. This might be an overcommit issue or out of memory."
CHECK(ret>=0 && ret<=256) << "Run cmd failed:" << cmd <<
"\nreturn ">> ret >> ". This might be an overcommit issue or out of memory."
<< "Try : sudo sysctl vm.overcommit_memory=1";
CHECKop(ret,==,0) << "Run cmd failed:" << cmd;
}