本文整理汇总了C++中__mempcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ __mempcpy函数的具体用法?C++ __mempcpy怎么用?C++ __mempcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了__mempcpy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getttyname
static char *
getttyname (int fd, dev_t mydev, ino_t myino, int save, int *dostat)
{
static const char dev[] = "/dev";
static size_t namelen;
struct stat st;
DIR *dirstream;
struct dirent *d;
dirstream = __opendir (dev);
if (dirstream == NULL)
{
*dostat = -1;
return NULL;
}
while ((d = __readdir (dirstream)) != NULL)
if (((ino_t) d->d_fileno == myino || *dostat)
&& strcmp (d->d_name, "stdin")
&& strcmp (d->d_name, "stdout")
&& strcmp (d->d_name, "stderr"))
{
size_t dlen = _D_ALLOC_NAMLEN (d);
if (sizeof (dev) + dlen > namelen)
{
free (getttyname_name);
namelen = 2 * (sizeof (dev) + dlen); /* Big enough. */
getttyname_name = malloc (namelen);
if (! getttyname_name)
{
*dostat = -1;
/* Perhaps it helps to free the directory stream buffer. */
(void) __closedir (dirstream);
return NULL;
}
*((char *) __mempcpy (getttyname_name, dev, sizeof (dev) - 1))
= '/';
}
(void) __mempcpy (&getttyname_name[sizeof (dev)], d->d_name, dlen);
if (stat (getttyname_name, &st) == 0
#ifdef _STATBUF_ST_RDEV
&& S_ISCHR (st.st_mode) && st.st_rdev == mydev
#else
&& (ino_t) d->d_fileno == myino && st.st_dev == mydev
#endif
)
{
(void) __closedir (dirstream);
__ttyname = getttyname_name;
__set_errno (save);
return getttyname_name;
}
}
(void) __closedir (dirstream);
__set_errno (save);
return NULL;
}
开发者ID:riscv,项目名称:riscv-glibc,代码行数:58,代码来源:ttyname.c
示例2: msort_with_tmp
static void
msort_with_tmp (void *b, size_t n, size_t s, __compar_fn_t cmp,
char *t)
{
char *tmp;
char *b1, *b2;
size_t n1, n2;
if (n <= 1)
return;
n1 = n / 2;
n2 = n - n1;
b1 = b;
b2 = (char *) b + (n1 * s);
msort_with_tmp (b1, n1, s, cmp, t);
msort_with_tmp (b2, n2, s, cmp, t);
tmp = t;
if (s == OPSIZ && (b1 - (char *) 0) % OPSIZ == 0)
/* We are operating on aligned words. Use direct word stores. */
while (n1 > 0 && n2 > 0)
{
if ((*cmp) (b1, b2) <= 0)
{
--n1;
*((op_t *) tmp)++ = *((op_t *) b1)++;
}
else
{
--n2;
*((op_t *) tmp)++ = *((op_t *) b2)++;
}
}
else
while (n1 > 0 && n2 > 0)
{
if ((*cmp) (b1, b2) <= 0)
{
tmp = (char *) __mempcpy (tmp, b1, s);
b1 += s;
--n1;
}
else
{
tmp = (char *) __mempcpy (tmp, b2, s);
b2 += s;
--n2;
}
}
if (n1 > 0)
memcpy (tmp, b1, n1 * s);
memcpy (b, t, (n - n2) * s);
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:56,代码来源:msort.c
示例3: _IO_file_xsgetn_mmap
static _IO_size_t
_IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n)
{
_IO_size_t have;
char *read_ptr = fp->_IO_read_ptr;
char *s = (char *) data;
have = fp->_IO_read_end - fp->_IO_read_ptr;
if (have < n)
{
if (__glibc_unlikely (_IO_in_backup (fp)))
{
#ifdef _LIBC
s = __mempcpy (s, read_ptr, have);
#else
memcpy (s, read_ptr, have);
s += have;
#endif
n -= have;
_IO_switch_to_main_get_area (fp);
read_ptr = fp->_IO_read_ptr;
have = fp->_IO_read_end - fp->_IO_read_ptr;
}
if (have < n)
{
/* Check that we are mapping all of the file, in case it grew. */
if (__glibc_unlikely (mmap_remap_check (fp)))
/* We punted mmap, so complete with the vanilla code. */
return s - (char *) data + _IO_XSGETN (fp, data, n);
read_ptr = fp->_IO_read_ptr;
have = fp->_IO_read_end - read_ptr;
}
}
if (have < n)
fp->_flags |= _IO_EOF_SEEN;
if (have != 0)
{
have = MIN (have, n);
#ifdef _LIBC
s = __mempcpy (s, read_ptr, have);
#else
memcpy (s, read_ptr, have);
s += have;
#endif
fp->_IO_read_ptr = read_ptr + have;
}
return s - (char *) data;
}
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:54,代码来源:fileops.c
示例4: shm_open
/* Open shared memory object. This implementation assumes the shmfs
implementation introduced in the late 2.3.x kernel series to be
available. Normally the filesystem will be mounted at /dev/shm but
we fall back on searching for the actual mount point should opening
such a file fail. */
int
shm_open (const char *name, int oflag, mode_t mode)
{
size_t namelen;
char *fname;
int fd;
/* Determine where the shmfs is mounted. */
__libc_once (once, where_is_shmfs);
/* If we don't know the mount points there is nothing we can do. Ever. */
if (mountpoint.dir == NULL)
{
__set_errno (ENOSYS);
return -1;
}
/* Construct the filename. */
while (name[0] == '/')
++name;
namelen = strlen (name);
/* Validate the filename. */
if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') != NULL)
{
__set_errno (EINVAL);
return -1;
}
fname = (char *) alloca (mountpoint.dirlen + namelen + 1);
__mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen),
name, namelen + 1);
/* And get the file descriptor.
XXX Maybe we should test each descriptor whether it really is for a
file on the shmfs. If this is what should be done the whole function
should be revamped since we can determine whether shmfs is available
while trying to open the file, all in one turn. */
fd = open (fname, oflag | O_CLOEXEC | O_NOFOLLOW, mode);
if (fd == -1 && __glibc_unlikely (errno == EISDIR))
/* It might be better to fold this error with EINVAL since
directory names are just another example for unsuitable shared
object names and the standard does not mention EISDIR. */
__set_errno (EINVAL);
return fd;
}
开发者ID:bluecmd,项目名称:or1k-glibc,代码行数:53,代码来源:shm_open.c
示例5: nis_leaf_of_r
nis_name
nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen)
{
size_t i = 0;
buffer[0] = '\0';
while (name[i] != '.' && name[i] != '\0')
i++;
if (i > buflen - 1)
{
__set_errno (ERANGE);
return NULL;
}
if (i > 0)
{
if ((size_t)i >= buflen)
{
__set_errno (ERANGE);
return NULL;
}
*((char *) __mempcpy (buffer, name, i)) = '\0';
}
return buffer;
}
开发者ID:mbref,项目名称:glibc-236-microblaze,代码行数:29,代码来源:nis_subr.c
示例6: nis_name_of_r
nis_name
nis_name_of_r (const_nis_name name, char *buffer, size_t buflen)
{
char *local_domain;
int diff;
local_domain = nis_local_directory ();
diff = strlen (name) - strlen (local_domain);
if (diff <= 0)
return NULL;
if (strcmp (&name[diff], local_domain) != 0)
return NULL;
if ((size_t) diff >= buflen)
{
__set_errno (ERANGE);
return NULL;
}
*((char *) __mempcpy (buffer, name, diff - 1)) = '\0';
if (diff - 1 == 0)
return NULL;
return buffer;
}
开发者ID:JamesLinus,项目名称:glibc-mips,代码行数:28,代码来源:nis_subr.c
示例7: _IO_obstack_xsputn
static _IO_size_t
_IO_obstack_xsputn (_IO_FILE *fp, const void *data, _IO_size_t n)
{
struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;
if (fp->_IO_write_ptr + n > fp->_IO_write_end)
{
int size;
/* We need some more memory. First shrink the buffer to the
space we really currently need. */
obstack_blank_fast (obstack, fp->_IO_write_ptr - fp->_IO_write_end);
/* Now grow for N bytes, and put the data there. */
obstack_grow (obstack, data, n);
/* Setup the buffer pointers again. */
fp->_IO_write_base = obstack_base (obstack);
fp->_IO_write_ptr = obstack_next_free (obstack);
size = obstack_room (obstack);
fp->_IO_write_end = fp->_IO_write_ptr + size;
/* Now allocate the rest of the current chunk. */
obstack_blank_fast (obstack, size);
}
else
fp->_IO_write_ptr = __mempcpy (fp->_IO_write_ptr, data, n);
return n;
}
开发者ID:AubrCool,项目名称:glibc,代码行数:29,代码来源:obprintf.c
示例8: find_module
static int
internal_function
find_module (const char *directory, const char *filename,
struct __gconv_step *result)
{
size_t dirlen = strlen (directory);
size_t fnamelen = strlen (filename) + 1;
char fullname[dirlen + fnamelen];
int status = __GCONV_NOCONV;
memcpy (__mempcpy (fullname, directory, dirlen), filename, fnamelen);
result->__shlib_handle = __gconv_find_shlib (fullname);
if (result->__shlib_handle != NULL)
{
status = __GCONV_OK;
result->__modname = NULL;
result->__fct = result->__shlib_handle->fct;
result->__init_fct = result->__shlib_handle->init_fct;
result->__end_fct = result->__shlib_handle->end_fct;
/* These settings can be overridden by the init function. */
result->__btowc_fct = NULL;
result->__data = NULL;
/* Call the init function. */
if (result->__init_fct != NULL)
status = DL_CALL_FCT (result->__init_fct, (result));
}
return status;
}
开发者ID:mmanley,项目名称:Antares,代码行数:33,代码来源:gconv_cache.c
示例9: __getpt
/* Open a master pseudo terminal and return its file descriptor. */
int
__getpt (void)
{
char buf[sizeof (_PATH_PTY) + 2];
const char *p, *q;
char *s;
s = __mempcpy (buf, _PATH_PTY, sizeof (_PATH_PTY) - 1);
/* s[0] and s[1] will be filled in the loop. */
s[2] = '\0';
for (p = __libc_ptyname1; *p != '\0'; ++p)
{
s[0] = *p;
for (q = __libc_ptyname2; *q != '\0'; ++q)
{
int fd;
s[1] = *q;
fd = __open (buf, O_RDWR);
if (fd != -1)
return fd;
if (errno == ENOENT)
return -1;
}
}
__set_errno (ENOENT);
return -1;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:34,代码来源:getpt.c
示例10: _dl_get_origin
const char *
_dl_get_origin (void)
{
char linkval[PATH_MAX];
char *result;
int len;
INTERNAL_SYSCALL_DECL (err);
len = INTERNAL_SYSCALL (readlinkat, err, 4, AT_FDCWD, "/proc/self/exe",
linkval, sizeof (linkval));
if (! INTERNAL_SYSCALL_ERROR_P (len, err) && len > 0 && linkval[0] != '[')
{
/* We can use this value. */
assert (linkval[0] == '/');
while (len > 1 && linkval[len - 1] != '/')
--len;
result = (char *) malloc (len + 1);
if (result == NULL)
result = (char *) -1;
else if (len == 1)
memcpy (result, "/", 2);
else
*((char *) __mempcpy (result, linkval, len - 1)) = '\0';
}
else
{
result = (char *) -1;
/* We use the environment variable LD_ORIGIN_PATH. If it is set make
a copy and strip out trailing slashes. */
if (GLRO(dl_origin_path) != NULL)
{
size_t len = strlen (GLRO(dl_origin_path));
result = (char *) malloc (len + 1);
if (result == NULL)
result = (char *) -1;
else
{
char *cp = __mempcpy (result, GLRO(dl_origin_path), len);
while (cp > result + 1 && cp[-1] == '/')
--cp;
*cp = '\0';
}
}
}
return result;
}
开发者ID:AubrCool,项目名称:glibc,代码行数:47,代码来源:dl-origin.c
示例11: getttyname
internal_function attribute_compat_text_section
getttyname (const char *dev, dev_t mydev, ino64_t myino, int save, int *dostat)
{
static size_t namelen;
struct stat64 st;
DIR *dirstream;
struct dirent64 *d;
size_t devlen = strlen (dev) + 1;
dirstream = __opendir (dev);
if (dirstream == NULL)
{
*dostat = -1;
return NULL;
}
while ((d = __readdir64 (dirstream)) != NULL)
if ((d->d_fileno == myino || *dostat)
&& strcmp (d->d_name, "stdin")
&& strcmp (d->d_name, "stdout")
&& strcmp (d->d_name, "stderr"))
{
size_t dlen = _D_ALLOC_NAMLEN (d);
if (devlen + dlen > namelen)
{
free (getttyname_name);
namelen = 2 * (devlen + dlen); /* Big enough. */
getttyname_name = malloc (namelen);
if (! getttyname_name)
{
*dostat = -1;
/* Perhaps it helps to free the directory stream buffer. */
(void) __closedir (dirstream);
return NULL;
}
*((char *) __mempcpy (getttyname_name, dev, devlen - 1)) = '/';
}
memcpy (&getttyname_name[devlen], d->d_name, dlen);
if (__xstat64 (_STAT_VER, getttyname_name, &st) == 0
#ifdef _STATBUF_ST_RDEV
&& S_ISCHR (st.st_mode) && st.st_rdev == mydev
#else
&& d->d_fileno == myino && st.st_dev == mydev
#endif
)
{
(void) __closedir (dirstream);
#if 0
__ttyname = getttyname_name;
#endif
__set_errno (save);
return getttyname_name;
}
}
(void) __closedir (dirstream);
__set_errno (save);
return NULL;
}
开发者ID:Lind-Project,项目名称:Lind-GlibC,代码行数:59,代码来源:ttyname.c
示例12: __mempcpy_chk
void *
__mempcpy_chk (void *dstpp, const void *srcpp, size_t len, size_t dstlen)
{
if (__glibc_unlikely (dstlen < len))
__chk_fail ();
return __mempcpy (dstpp, srcpp, len);
}
开发者ID:Distrotech,项目名称:glibc,代码行数:8,代码来源:mempcpy_chk.c
示例13: __wmempcpy_chk
wchar_t *
__wmempcpy_chk (wchar_t *s1, const wchar_t *s2, size_t n, size_t ns1)
{
if (__glibc_unlikely (ns1 < n))
__chk_fail ();
return (wchar_t *) __mempcpy ((char *) s1, (char *) s2,
n * sizeof (wchar_t));
}
开发者ID:JamesLinus,项目名称:glibc-mips,代码行数:8,代码来源:wmempcpy_chk.c
示例14: getttyname
internal_function
getttyname (const char *dev, dev_t mydev, ino64_t myino, int save)
{
static size_t namelen;
struct stat64 st;
DIR *dirstream;
struct dirent *d;
size_t devlen = strlen (dev) + 1;
dirstream = __opendir (dev);
if (dirstream == NULL)
{
return NULL;
}
while ((d = __readdir (dirstream)) != NULL)
if (d->d_fileno == myino)
{
size_t dlen = _D_ALLOC_NAMLEN (d);
if (devlen + dlen > namelen)
{
free (getttyname_name);
namelen = 2 * (devlen + dlen); /* Big enough. */
getttyname_name = malloc (namelen);
if (! getttyname_name)
{
/* Perhaps it helps to free the directory stream buffer. */
(void) __closedir (dirstream);
return NULL;
}
}
/* Always recopy dev since it may be master or slave. */
*((char *) __mempcpy (getttyname_name, dev, devlen - 1)) = '/';
memcpy (&getttyname_name[devlen], d->d_name, dlen);
if (__xstat64 (_STAT_VER, getttyname_name, &st) == 0
#ifdef _STATBUF_ST_RDEV
&& S_ISCHR (st.st_mode) && st.st_rdev == mydev
#else
&& d->d_fileno == myino && st.st_dev == mydev
#endif
)
{
(void) __closedir (dirstream);
#if 0
__ttyname = getttyname_name;
#endif
__set_errno (save);
return getttyname_name;
}
}
(void) __closedir (dirstream);
__set_errno (save);
return NULL;
}
开发者ID:rickcaudill,项目名称:Pyro,代码行数:56,代码来源:ttyname.c
示例15: _hurd_xattr_list
error_t
_hurd_xattr_list (io_t port, void *buffer, size_t *size)
{
size_t total = 0;
char *bufp = buffer;
inline void add (const char *name, size_t len)
{
total += len;
if (bufp != NULL && total <= *size)
bufp = __mempcpy (bufp, name, len);
}
开发者ID:abellgithub,项目名称:glibc,代码行数:11,代码来源:xattr.c
示例16: shm_unlink
/* Unlink a shared memory object. */
int
shm_unlink (const char *name)
{
size_t namelen;
char *fname;
/* Determine where the shmfs is mounted. */
__libc_once (once, where_is_shmfs);
if (mountpoint.dir == NULL)
{
/* We cannot find the shmfs. If `name' is really a shared
memory object it must have been created by another process
and we have no idea where that process found the mountpoint. */
__set_errno (ENOENT);
return -1;
}
/* Construct the filename. */
while (name[0] == '/')
++name;
namelen = strlen (name);
/* Validate the filename. */
if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') != NULL)
{
__set_errno (ENOENT);
return -1;
}
fname = (char *) alloca (mountpoint.dirlen + namelen + 1);
__mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen),
name, namelen + 1);
/* And remove the file. */
int ret = unlink (fname);
if (ret < 0 && errno == EPERM)
__set_errno (EACCES);
return ret;
}
开发者ID:bluecmd,项目名称:or1k-glibc,代码行数:42,代码来源:shm_open.c
示例17: __libc_writev
/* Write data pointed by the buffers described by VECTOR, which
is a vector of COUNT 'struct iovec's, to file descriptor FD.
The data is written in the order specified.
Operates just like 'write' (see <unistd.h>) except that the data
are taken from VECTOR instead of a contiguous buffer. */
ssize_t
__libc_writev (int fd, const struct iovec *vector, int count)
{
/* Find the total number of bytes to be written. */
size_t bytes = 0;
for (int i = 0; i < count; ++i)
{
/* Check for ssize_t overflow. */
if (SSIZE_MAX - bytes < vector[i].iov_len)
{
__set_errno (EINVAL);
return -1;
}
bytes += vector[i].iov_len;
}
/* Allocate a temporary buffer to hold the data. We should normally
use alloca since it's faster and does not require synchronization
with other threads. But we cannot if the amount of memory
required is too large. */
char *buffer;
char *malloced_buffer = NULL;
if (__libc_use_alloca (bytes))
buffer = (char *) __alloca (bytes);
else
{
malloced_buffer = buffer = (char *) malloc (bytes);
if (buffer == NULL)
/* XXX I don't know whether it is acceptable to try writing
the data in chunks. Probably not so we just fail here. */
return -1;
}
/* Copy the data into BUFFER. */
size_t to_copy = bytes;
char *bp = buffer;
for (int i = 0; i < count; ++i)
{
size_t copy = MIN (vector[i].iov_len, to_copy);
bp = __mempcpy ((void *) bp, (void *) vector[i].iov_base, copy);
to_copy -= copy;
if (to_copy == 0)
break;
}
ssize_t bytes_written = __write (fd, buffer, bytes);
free(malloced_buffer);
return bytes_written;
}
开发者ID:kstraube,项目名称:rampgold_fixed,代码行数:58,代码来源:writev.c
示例18: shm_unlink
/* Remove shared memory object. */
int
shm_unlink (const char *name)
{
size_t namelen;
char *fname;
/* Construct the filename. */
while (name[0] == '/')
++name;
if (name[0] == '\0')
{
/* The name "/" is not supported. */
__set_errno (EINVAL);
return -1;
}
namelen = strlen (name);
fname = (char *) __alloca (sizeof SHMDIR - 1 + namelen + 1);
__mempcpy (__mempcpy (fname, SHMDIR, sizeof SHMDIR - 1),
name, namelen + 1);
return unlink (name);
}
开发者ID:imbaqian,项目名称:glibc,代码行数:25,代码来源:shm_unlink.c
示例19: internal_ucs4le_loop_unaligned
internal_ucs4le_loop_unaligned (struct __gconv_step *step,
struct __gconv_step_data *step_data,
const unsigned char **inptrp,
const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend,
size_t *irreversible)
{
const unsigned char *inptr = *inptrp;
unsigned char *outptr = *outptrp;
size_t n_convert = MIN (inend - inptr, outend - outptr) / 4;
int result;
# if __BYTE_ORDER == __BIG_ENDIAN
/* Sigh, we have to do some real work. */
size_t cnt;
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4)
{
outptr[0] = inptr[3];
outptr[1] = inptr[2];
outptr[2] = inptr[1];
outptr[3] = inptr[0];
}
*inptrp = inptr;
*outptrp = outptr;
# elif __BYTE_ORDER == __LITTLE_ENDIAN
/* Simply copy the data. */
*inptrp = inptr + n_convert * 4;
*outptrp = __mempcpy (outptr, inptr, n_convert * 4);
# else
# error "This endianess is not supported."
# endif
/* Determine the status. */
if (*inptrp == inend)
result = __GCONV_EMPTY_INPUT;
else if (*inptrp + 4 > inend)
result = __GCONV_INCOMPLETE_INPUT;
else
{
assert (*outptrp + 4 > outend);
result = __GCONV_FULL_OUTPUT;
}
return result;
}
开发者ID:Xilinx,项目名称:glibc,代码行数:47,代码来源:gconv_simple.c
示例20: str_append
/* Append BUF, of length BUF_LEN to *TO, of length *TO_LEN, reallocating and
updating *TO & *TO_LEN appropriately. If an allocation error occurs,
*TO's old value is freed, and *TO is set to 0. */
static void
str_append (char **to, size_t *to_len, const char *buf, const size_t buf_len)
{
size_t new_len = *to_len + buf_len;
char *new_to = realloc (*to, new_len + 1);
if (new_to)
{
*((char *) __mempcpy (new_to + *to_len, buf, buf_len)) = '\0';
*to = new_to;
*to_len = new_len;
}
else
{
free (*to);
*to = 0;
}
}
开发者ID:AubrCool,项目名称:glibc,代码行数:21,代码来源:argz-replace.c
注:本文中的__mempcpy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论