本文整理汇总了C++中LEN_AND_LIT函数的典型用法代码示例。如果您正苦于以下问题:C++ LEN_AND_LIT函数的具体用法?C++ LEN_AND_LIT怎么用?C++ LEN_AND_LIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LEN_AND_LIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: times_usec
STATICFNDEF void times_usec(ext_tms *curr)
{
int res;
struct rusage usage;
struct timespec elp_time;
res = getrusage(RUSAGE_SELF, &usage);
if (res == -1)
MPROF_RTS_ERROR((VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("getrusage"), CALLFROM, errno));
curr->tms_utime = (usage.ru_utime.tv_sec * (gtm_uint64_t)1000000) + usage.ru_utime.tv_usec;
curr->tms_stime = (usage.ru_stime.tv_sec * (gtm_uint64_t)1000000) + usage.ru_stime.tv_usec;
/* also start recording the elapsed time */
while (TRUE)
{
res = clock_gettime(use_realtime_flag ? CLOCK_REALTIME : CLOCK_MONOTONIC, &elp_time);
if (res == -1)
{
if ((EINVAL == errno) && !use_realtime_flag)
{
use_realtime_flag = TRUE;
continue;
} else
MPROF_RTS_ERROR((VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("clock_gettime"), CALLFROM, errno));
}
break;
}
curr->tms_etime = (elp_time.tv_sec * (gtm_uint64_t)1000000) + (elp_time.tv_nsec / 1000);
return;
}
示例2: times_usec
STATICFNDEF void times_usec(ext_tms *curr)
{
int res;
struct rusage usage;
struct timespec elp_time;
res = getrusage(RUSAGE_SELF, &usage);
if (-1 == res)
MPROF_RTS_ERROR((CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("getrusage"), CALLFROM, errno));
# ifdef __osf__
/* On Tru64 getrusage sometimes fails to increment the seconds value when the microseconds wrap around at 1M. If we detect
* this, we make a second call to getrusage if so. A more complete check would be to also verify whether the new seconds
* value is less than the previous one, but we anyway have an assert in UPDATE_TIME that would catch that, and our testing
* on Tru64 has not shown that type of faulty behavior.
*/
if (((usage.ru_utime.tv_sec == last_usage.ru_utime.tv_sec) && (usage.ru_utime.tv_usec < last_usage.ru_utime.tv_usec))
|| ((usage.ru_stime.tv_sec == last_usage.ru_stime.tv_sec) && (usage.ru_stime.tv_usec < last_usage.ru_stime.tv_usec)))
{
DEBUG_ONLY(last_usage = usage);
res = getrusage(RUSAGE_SELF, &usage);
if (-1 == res)
MPROF_RTS_ERROR((CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("getrusage"), CALLFROM, errno));
/* In debug also ensure that a subsequent call to getrusage restored the seconds value. */
assert((usage.ru_utime.tv_sec > last_usage.ru_utime.tv_sec)
|| (usage.ru_stime.tv_sec > last_usage.ru_stime.tv_sec));
}
last_usage = usage;
# endif
curr->tms_utime = (usage.ru_utime.tv_sec * (gtm_uint64_t)1000000) + usage.ru_utime.tv_usec;
curr->tms_stime = (usage.ru_stime.tv_sec * (gtm_uint64_t)1000000) + usage.ru_stime.tv_usec;
/* Also start recording the elapsed time. */
while (TRUE)
{
res = clock_gettime(use_realtime_flag ? CLOCK_REALTIME : CLOCK_MONOTONIC, &elp_time);
if (res == -1)
{
if ((EINVAL == errno) && !use_realtime_flag)
{
use_realtime_flag = TRUE;
continue;
} else
MPROF_RTS_ERROR((CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5,
LEN_AND_LIT("clock_gettime"), CALLFROM, errno));
}
break;
}
curr->tms_etime = (elp_time.tv_sec * (gtm_uint64_t)1000000) + (elp_time.tv_nsec / 1000);
return;
}
示例3: gtcm_open_cmerrlog
void gtcm_open_cmerrlog(void)
{
int len;
mstr lfn1, lfn2;
char lfn_path[MAX_TRANS_NAME_LEN + 1];
char new_lfn_path[MAX_TRANS_NAME_LEN + 1];
int new_len;
uint4 ustatus;
int4 rval;
FILE *new_file;
error_def(ERR_TEXT);
if (0 != (len = STRLEN(gtcm_gnp_server_log)))
{
lfn1.addr = gtcm_gnp_server_log;
lfn1.len = len;
} else
{
lfn1.addr = GTCM_GNP_CMERR_FN;
lfn1.len = sizeof(GTCM_GNP_CMERR_FN) - 1;
}
rval = TRANS_LOG_NAME(&lfn1, &lfn2, lfn_path, sizeof(lfn_path), do_sendmsg_on_log2long);
if (rval == SS_NORMAL || rval == SS_NOLOGNAM)
{
lfn_path[lfn2.len] = 0;
rename_file_if_exists(lfn_path, lfn2.len, new_lfn_path, &new_len, &ustatus);
new_file = Fopen(lfn_path, "a");
if (NULL != new_file)
{
gtcm_errfile = TRUE;
if (gtcm_errfs)
fclose(gtcm_errfs);
gtcm_errfs = new_file;
if (dup2(fileno(gtcm_errfs), 1) < 0)
{
rts_error(VARLSTCNT(5) ERR_TEXT, 2, LEN_AND_LIT("Error on dup2 of stdout"), errno);
}
if (dup2(fileno(gtcm_errfs), 2) < 0)
{
rts_error(VARLSTCNT(5) ERR_TEXT, 2, LEN_AND_LIT("Error on dup2 of stderr"), errno);
}
}
else
fprintf(stderr, "Unable to open %s : %s\n", lfn_path, STRERROR(errno));
} else
fprintf(stderr, "Unable to resolve %s : return value = %d\n", GTCM_GNP_CMERR_FN, rval);
gtcm_firsterr = FALSE;
}
示例4: gvcmx_increment
/* returns FALSE if gv_currkey is undefined in the server end and undef_inhibit is turned OFF */
void gvcmx_increment(mval *increment, mval *result)
{
unsigned char buff[MAX_ZWR_KEY_SZ], *end;
mval tmpmval;
error_def(ERR_UNIMPLOP);
error_def(ERR_TEXT);
error_def(ERR_GVIS);
if (!((link_info *)gv_cur_region->dyn.addr->cm_blk->usr)->server_supports_dollar_incr)
{
assert(dba_cm == gv_cur_region->dyn.addr->acc_meth); /* we should've covered all other access methods elsewhere */
end = format_targ_key(buff, MAX_ZWR_KEY_SZ, gv_currkey, TRUE);
rts_error(VARLSTCNT(14) ERR_UNIMPLOP, 0,
ERR_TEXT, 2, LEN_AND_LIT("GT.CM server does not support $INCREMENT operation"),
ERR_GVIS, 2, end - buff, buff,
ERR_TEXT, 2, REG_LEN_STR(gv_cur_region));
}
/* gvcmz_doop() currently accepts only one argument.
* It serves as an input argument for SET.
* It serves as an output argument for GET etc.
* $INCR is unique in that it needs to pass the increment as input and expects the post-increment as output.
*
* In order to accomplish this without changing the gvcmz_doop() interface, we overload the one argument to
* serve two purposes. It will be an input argument until the send of the message to the server and will
* then serve as an output argument after the response from the server. ("result" is used for this purpose)
* i.e.
* to serve as increment for client --> server message
* to serve as post-increment value for server --> client message
*/
assert(MV_IS_NUMERIC(increment)); /* op_gvincr would have forced it to be a NUMERIC */
MV_FORCE_STR(increment); /* convert it to a string before sending it to gvcmz_doop */
*result = *increment;
gvcmz_doop(CMMS_Q_INCREMENT, CMMS_R_INCREMENT, result);
}
示例5: dollar_system_init
void dollar_system_init(struct startup_vector *svec)
{
uint4 status;
mstr val, tn;
char buf[MAX_TRANS_NAME_LEN];
error_def(ERR_TRNLOGFAIL);
dollar_system.mvtype = MV_STR;
dollar_system.str.addr = (char *)stringpool.free;
dollar_system.str.len = STR_LIT_LEN("47,");
memcpy(stringpool.free, "47,", dollar_system.str.len);
stringpool.free += dollar_system.str.len;
val.addr = SYSID;
val.len = STR_LIT_LEN(SYSID);
if (SS_NORMAL == (status = trans_log_name(&val, &tn, buf)))
{
dollar_system.str.len += tn.len;
memcpy(stringpool.free, tn.addr, tn.len);
stringpool.free += tn.len;
} else if (SS_NOLOGNAM == status)
{
dollar_system.str.len += svec->sysid_ptr->len;
memcpy(stringpool.free, svec->sysid_ptr->addr, svec->sysid_ptr->len);
stringpool.free += dollar_system.str.len;
} else
rts_error(VARLSTCNT(5) ERR_TRNLOGFAIL, 2, LEN_AND_LIT(SYSID), status);
assert(stringpool.free < stringpool.top); /* it's process initialization after all */
return;
}
示例6: fgn_getrtn
/* Lookup an external function. Return function address if success, NULL otherwise.
* package_handle - DLL handle returned by fgn_getpak
* entry_name - symbol name to be looked up
* msgtype - message severity of the errors reported if any.
* Note: If msgtype is SUCCESS, errors are not issued. It is useful if the callers are not
* interested in message report and not willing to have condition handler overhead (eg. zro_search).
*/
fgnfnc fgn_getrtn(void_ptr_t package_handle, mstr *entry_name, int msgtype)
{
void_ptr_t sym_addr;
char_ptr_t dummy_err_str;
void *short_sym_addr;
char err_str[MAX_ERRSTR_LEN]; /* needed as util_out_print doesn't handle 64bit pointers */
error_def(ERR_DLLNORTN);
error_def(ERR_TEXT);
if (!(sym_addr = dlsym(package_handle, entry_name->addr)))
{
if (SUCCESS != msgtype)
{
assert(!(msgtype & ~SEV_MSK));
COPY_DLLERR_MSG;
rts_error(VARLSTCNT(8) MAKE_MSG_TYPE(ERR_DLLNORTN, msgtype), 2, LEN_AND_STR(entry_name->addr),
ERR_TEXT, 2, LEN_AND_STR(err_str));
}
} else
{ /* Tru64 - dlsym() is bound to return short pointer because of ld -taso flag used for GT.M */
#ifdef __osf__
short_sym_addr = sym_addr;
if (short_sym_addr != sym_addr)
{
sym_addr = NULL;
/* always report an error irrespective of msgtype - since this code should never
* have executed and/or the DLL might need to be rebuilt with 32-bit options */
rts_error(VARLSTCNT(8) ERR_DLLNORTN, 2, LEN_AND_STR(entry_name->addr),
ERR_TEXT, 2, LEN_AND_LIT("Symbol is loaded above the lower 31-bit address space"));
}
#endif
}
return (fgnfnc)sym_addr;
}
示例7: gtmrecv_statslog
int gtmrecv_statslog(void)
{
#ifdef VMS
rts_error(VARLSTCNT(6) ERR_UNIMPLOP, 0, ERR_TEXT, 2, LEN_AND_LIT("Statistics logging not supported on VMS"));
#endif
/* Grab the recvpool option write lock */
if (0 > grab_sem(RECV, RECV_SERV_OPTIONS_SEM))
{
util_out_print("Error grabbing recvpool option write lock. Could not initiate stats log", TRUE);
return (ABNORMAL_SHUTDOWN);
}
if (gtmrecv_options.statslog == recvpool.gtmrecv_local->statslog)
{
util_out_print("STATSLOG is already !AD. Not initiating change in stats log", TRUE, gtmrecv_options.statslog ?
strlen("ON") : strlen("OFF"), gtmrecv_options.statslog ? "ON" : "OFF");
rel_sem_immediate(RECV, RECV_SERV_OPTIONS_SEM);
return (ABNORMAL_SHUTDOWN);
}
if (!gtmrecv_options.statslog)
{
recvpool.gtmrecv_local->statslog = FALSE;
util_out_print("STATSLOG turned OFF", TRUE);
rel_sem_immediate(RECV, RECV_SERV_OPTIONS_SEM);
return (NORMAL_SHUTDOWN);
}
recvpool.gtmrecv_local->statslog = TRUE;
util_out_print("Stats log turned on", TRUE);
rel_sem_immediate(RECV, RECV_SERV_OPTIONS_SEM);
return (NORMAL_SHUTDOWN);
}
示例8: update_trigger_name_value
STATICFNDEF int4 update_trigger_name_value(char *trig_name, int trig_name_len, int new_trig_index)
{
int len;
char name_and_index[MAX_MIDENT_LEN + 1 + MAX_DIGITS_IN_INT];
int num_len;
char *ptr;
int4 result;
mval trig_gbl;
DCL_THREADGBL_ACCESS;
SETUP_THREADGBL_ACCESS;
assert(!gv_cur_region->read_only); /* caller should have already checked this */
assert(cs_addrs->hasht_tree == gv_target); /* should have been set up by caller */
assert(gv_target->root); /* should have been ensured by caller */
/* $get(^#t("#TNAME",^#t(GVN,index,"#TRIGNAME"))) */
BUILD_HASHT_SUB_SUB_CURRKEY(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1);
if (!gvcst_get(&trig_gbl))
{ /* There has to be a #TNAME entry */
if (CDB_STAGNATE > t_tries)
t_retry(cdb_sc_triggermod);
assert(WBTEST_HELPOUT_TRIGDEFBAD == gtm_white_box_test_case_number);
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_TRIGNAMBAD, 4, LEN_AND_LIT("\"#TNAME\""),
trig_name_len - 1, trig_name);
}
ptr = trig_gbl.str.addr;
len = MIN(trig_gbl.str.len, MAX_MIDENT_LEN);
STRNLEN(ptr, len, len);
ptr += len;
if ((trig_gbl.str.len == len) || ('\0' != *ptr))
{
if (CDB_STAGNATE > t_tries)
t_retry(cdb_sc_triggermod);
assert(WBTEST_HELPOUT_TRIGDEFBAD == gtm_white_box_test_case_number);
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_TRIGNAMBAD, 4, LEN_AND_LIT("\"#TNAME\""),
trig_name_len - 1, trig_name);
}
memcpy(name_and_index, trig_gbl.str.addr, ++len); /* inline increment intended */
ptr = name_and_index + len;
num_len = 0;
I2A(ptr, num_len, new_trig_index);
len += num_len;
/* set ^#t("#TNAME",<trigname>)=gblname_$C(0)_new_trig_index */
SET_TRIGGER_GLOBAL_SUB_SUB_STR(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1,
name_and_index, len, result);
return result;
}
示例9: gvcmy_open
void gvcmy_open(gd_region *reg, parse_blk *nb)
{
error_def(ERR_UNIMPLOP);
error_def(ERR_TEXT);
rts_error(VARLSTCNT(6) ERR_UNIMPLOP, 0, ERR_TEXT,
2, LEN_AND_LIT("This utility does not support remote database operations"));
}
示例10: mupfndfil
/* mupfndfil.c
* Description:
* For a region find if the corresponding database is present.
* Arguments:
* reg: Region's pointer
* filestr: Sent as allocated memory, if returned full path is needed in this mstr
* Returns: TRUE if region's database file is found
* FALSE, otherwise
* Side Effects:
* reg->dyn.addr->fname_len and reg->dyn.addr->fname are updated
*/
boolean_t mupfndfil(gd_region *reg, mstr *filestr)
{
char filename[MAX_FN_LEN];
mstr file, def, ret, *retptr;
uint4 ustatus;
switch(reg->dyn.addr->acc_meth)
{
case dba_mm:
case dba_bg:
break;
# ifdef VMS
case dba_usr:
gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_NOUSERDB, 4, LEN_AND_LIT("specified function"), REG_LEN_STR(reg));
return FALSE; /* This is currently a VMS only possibility and has no corresponding test case */
# endif
default:
util_out_print("REGION !AD has an unrecognized access method.", TRUE, REG_LEN_STR(reg));
return FALSE;
}
file.addr = (char *)reg->dyn.addr->fname;
file.len = reg->dyn.addr->fname_len;
#if defined(UNIX)
file.addr[file.len] = 0;
if (is_raw_dev(file.addr))
{
def.addr = DEF_NODBEXT;
def.len = SIZEOF(DEF_NODBEXT) - 1;
} else
{
def.addr = DEF_DBEXT; /* UNIX need to pass "*.dat" but reg->dyn.addr->defext has "DAT" */
def.len = SIZEOF(DEF_DBEXT) - 1;
}
#elif defined(VMS)
def.addr = (char *)reg->dyn.addr->defext;
def.len = SIZEOF(reg->dyn.addr->defext);
#endif
if (NULL == filestr)
{
ret.len = SIZEOF(filename);
ret.addr = filename;
retptr = &ret;
} else
retptr = filestr;
if (FILE_PRESENT != gtm_file_stat(&file, &def, retptr, FALSE, &ustatus))
{
if (!jgbl.mupip_journal)
{ /* Do not print error messages in case of call from mur_open_files().
* Currently we use "jgbl.mupip_journal" to identify a call from mupip_recover code */
util_out_print("REGION !AD's file !AD cannot be found.", TRUE, REG_LEN_STR(reg), LEN_AND_STR(file.addr));
gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(1) ustatus);
}
return FALSE;
}
reg->dyn.addr->fname_len = retptr->len;
memcpy(reg->dyn.addr->fname, retptr->addr, retptr->len + 1);
return TRUE;
}
示例11: times_usec
STATICFNDEF void times_usec(struct tms *curr)
{
int res;
struct rusage usage;
res = getrusage(RUSAGE_SELF, &usage);
if (res == -1)
rts_error(VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("getrusage"), CALLFROM, errno);
curr->tms_utime = (usage.ru_utime.tv_sec * 1000000) + usage.ru_utime.tv_usec;
curr->tms_stime = (usage.ru_stime.tv_sec * 1000000) + usage.ru_stime.tv_usec;
return;
}
示例12: update_trigger_name_value
STATICFNDEF int4 update_trigger_name_value(int trigvn_len, char *trig_name, int trig_name_len, int new_trig_index)
{
sgmnt_addrs *csa;
mname_entry gvent;
gv_namehead *hasht_tree;
int len;
char name_and_index[MAX_MIDENT_LEN + 1 + MAX_DIGITS_IN_INT];
char new_trig_name[MAX_TRIGNAME_LEN + 1];
int num_len;
char *ptr;
int4 result;
char save_currkey[SIZEOF(gv_key) + DBKEYSIZE(MAX_KEY_SZ)];
gv_key *save_gv_currkey;
gd_region *save_gv_cur_region;
gv_namehead *save_gv_target;
sgm_info *save_sgm_info_ptr;
mval trig_gbl;
DCL_THREADGBL_ACCESS;
SETUP_THREADGBL_ACCESS;
if (MAX_AUTO_TRIGNAME_LEN < trigvn_len)
return PUT_SUCCESS;
SAVE_TRIGGER_REGION_INFO;
SWITCH_TO_DEFAULT_REGION;
if (gv_cur_region->read_only)
rts_error_csa(CSA_ARG(csa) VARLSTCNT(4) ERR_TRIGMODREGNOTRW, 2, REG_LEN_STR(gv_cur_region));
assert(0 != gv_target->root);
/* $get(^#t("#TNAME",^#t(GVN,index,"#TRIGNAME")) */
BUILD_HASHT_SUB_SUB_CURRKEY(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1);
if (!gvcst_get(&trig_gbl))
{ /* There has to be a #TNAME entry */
if (CDB_STAGNATE > t_tries)
t_retry(cdb_sc_triggermod);
else
{
assert(WBTEST_HELPOUT_TRIGDEFBAD == gtm_white_box_test_case_number);
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_TRIGNAMBAD, 4, LEN_AND_LIT("\"#TNAME\""), trig_name_len - 1,
trig_name);
}
}
len = STRLEN(trig_gbl.str.addr) + 1;
assert(MAX_MIDENT_LEN >= len);
memcpy(name_and_index, trig_gbl.str.addr, len);
ptr = name_and_index + len;
num_len = 0;
I2A(ptr, num_len, new_trig_index);
len += num_len;
/* set ^#t(GVN,index,"#TRIGNAME")=trig_name $C(0) new_trig_index */
SET_TRIGGER_GLOBAL_SUB_SUB_STR(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1,
name_and_index, len, result);
RESTORE_TRIGGER_REGION_INFO;
return result;
}
示例13: get_cputime
STATICFNDEF void get_cputime (struct tms *curr)
{
int4 cpu_time_used;
int status;
int jpi_code = JPI$_CPUTIM;
if ((status = lib$getjpi(&jpi_code, &process_id, 0, &cpu_time_used, 0, 0)) != SS$_NORMAL)
rts_error(VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("LIB$GETJPI"), CALLFROM, status);
curr->tms_utime = cpu_time_used;
curr->tms_stime = 0;
return;
}
示例14: get_cputime
STATICFNDEF void get_cputime (ext_tms *curr)
{
int4 cpu_time_used;
int status;
int jpi_code = JPI$_CPUTIM;
if ((status = lib$getjpi(&jpi_code, &process_id, 0, &cpu_time_used, 0, 0)) != SS$_NORMAL)
MPROF_RTS_ERROR((CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("LIB$GETJPI"), CALLFROM, status));
curr->tms_utime = cpu_time_used;
curr->tms_stime = 0;
return;
}
示例15: child_times_usec
STATICFNDEF void child_times_usec(void)
{
int res;
struct rusage usage;
res = getrusage(RUSAGE_CHILDREN, &usage);
if (res == -1)
MPROF_RTS_ERROR((CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, LEN_AND_LIT("getrusage"), CALLFROM, errno));
child_user = (usage.ru_utime.tv_sec * (gtm_uint64_t)1000000) + usage.ru_utime.tv_usec;
child_system = (usage.ru_stime.tv_sec * (gtm_uint64_t)1000000) + usage.ru_stime.tv_usec;
return;
}