libc: Move memfd related stuff to sys/mman.h
follow the freebsd definition: https://github.com/freebsd/freebsd-src/blob/master/sys/sys/mman.h#L207-L228 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
0ef073573a
commit
dc2e9b8771
@ -1,72 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* include/sys/memfd.h
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __INCLUDE_SYS_MEMFD_H
|
|
||||||
#define __INCLUDE_SYS_MEMFD_H
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#define MFD_CLOEXEC O_CLOEXEC
|
|
||||||
#define MFD_ALLOW_SEALING (1 << 16)
|
|
||||||
#define MFD_HUGETLB (1 << 17)
|
|
||||||
|
|
||||||
#define MFD_HUGE_SHIFT 26
|
|
||||||
#define MFD_HUGE_MASK 0x3f
|
|
||||||
#define MFD_HUGE_64KB (16 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_512KB (19 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_1MB (20 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_2MB (21 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_8MB (23 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_16MB (24 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_32MB (25 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_256MB (28 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_512MB (29 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_1GB (30 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_2GB (31 << MFD_HUGE_SHIFT)
|
|
||||||
#define MFD_HUGE_16GB (34 << MFD_HUGE_SHIFT)
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Function Prototypes
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define EXTERN extern "C"
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int memfd_create(FAR const char *name, unsigned int flags);
|
|
||||||
|
|
||||||
#undef EXTERN
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __INCLUDE_SYS_MEMFD_H */
|
|
@ -128,6 +128,27 @@
|
|||||||
#define POSIX_TYPED_MEM_ALLOCATE_CONTIG (1)
|
#define POSIX_TYPED_MEM_ALLOCATE_CONTIG (1)
|
||||||
#define POSIX_TYPED_MEM_MAP_ALLOCATABLE (2)
|
#define POSIX_TYPED_MEM_MAP_ALLOCATABLE (2)
|
||||||
|
|
||||||
|
/* Flags for memfd_create(). */
|
||||||
|
|
||||||
|
#define MFD_CLOEXEC O_CLOEXEC
|
||||||
|
#define MFD_ALLOW_SEALING (1 << 16)
|
||||||
|
#define MFD_HUGETLB (1 << 17)
|
||||||
|
|
||||||
|
#define MFD_HUGE_SHIFT 26
|
||||||
|
#define MFD_HUGE_MASK 0x3f
|
||||||
|
#define MFD_HUGE_64KB (16 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_512KB (19 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_1MB (20 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_2MB (21 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_8MB (23 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_16MB (24 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_32MB (25 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_256MB (28 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_512MB (29 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_1GB (30 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_2GB (31 << MFD_HUGE_SHIFT)
|
||||||
|
#define MFD_HUGE_16GB (34 << MFD_HUGE_SHIFT)
|
||||||
|
|
||||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||||
# define mmap64 mmap
|
# define mmap64 mmap
|
||||||
#endif
|
#endif
|
||||||
@ -180,6 +201,7 @@ int posix_typed_mem_get_info(int fildes,
|
|||||||
int posix_typed_mem_open(FAR const char *name, int oflag, int tflag);
|
int posix_typed_mem_open(FAR const char *name, int oflag, int tflag);
|
||||||
int shm_open(FAR const char *name, int oflag, mode_t mode);
|
int shm_open(FAR const char *name, int oflag, mode_t mode);
|
||||||
int shm_unlink(FAR const char *name);
|
int shm_unlink(FAR const char *name);
|
||||||
|
int memfd_create(FAR const char *name, unsigned int flags);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <sys/memfd.h>
|
#include <sys/mman.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user