This commit is contained in:
2024-12-14 10:43:33 +03:00
parent 7f8090bb1f
commit bbf76e4925
1292 changed files with 2823 additions and 500876 deletions

View File

@@ -6,7 +6,7 @@
# 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
# 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,
@@ -15,7 +15,7 @@
# limitations under the License.
########
# 3.0.2
# 2.9.6
########
LOCAL_PATH := $(call my-dir)
@@ -23,41 +23,31 @@ LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/../build/config/env.mk
PMT_CXXFLAGS = \
-O3 \
-Wall \
-Wextra \
-Wno-vla-cxx-extension \
-Wno-nullability-completeness \
-Wno-writable-strings \
-Wno-nullability-extension \
-Wno-reorder-init-list \
-Wno-gnu-zero-variadic-macro-arguments \
-static \
$(PMT_EXTRA_CXXFLAGS)
-O3 \
-Wall \
-Wextra \
-Wno-vla-cxx-extension \
-Wno-nullability-completeness \
-Wno-writable-strings \
-Wno-nullability-extension \
-Wno-reorder-init-list \
-Wno-gnu-zero-variadic-macro-arguments \
-static \
$(PMT_EXTRA_CXXFLAGS)
E2FSPROGS_DEFAULT_CFLAGS = \
-Werror \
-Wno-pointer-arith \
-Wno-sign-compare \
-Wno-type-limits \
-Wno-typedef-redefinition \
-Wno-unused-parameter \
-Wno-unused-command-line-argument
PARTED_DEFAULTS_CFLAGS = \
-Wno-pointer-sign \
-Wno-sign-compare \
-Wno-gnu-designator \
-Wno-unused-variable \
-Wno-unused-parameter \
-Wno-unused-command-line-argument \
-Wno-missing-field-initializers \
-Wno-single-bit-bitfield-constant-conversion
-Werror \
-Wno-pointer-arith \
-Wno-sign-compare \
-Wno-type-limits \
-Wno-typedef-redefinition \
-Wno-unused-parameter \
-Wno-unused-command-line-argument
ifneq ($(PMT_ENABLE_DEBUG),)
PMT_CXXFLAGS += -gdwarf-5 -fsanitize=address
PMT_CXXFLAGS += -gdwarf-5 -fsanitize=address
endif
PMT := PartitionManager
PARTED := parted
MKE2FS := e2fsprogs/mke2fs
LIB := e2fsprogs/lib
LIBEXT2FS := $(LIB)/ext2fs
@@ -67,116 +57,111 @@ LIBEXT2_QUOTA := $(LIB)/support
LIBEXT2_MISC := $(LIB)/misc
LIBEXT2_COM_ERR := $(LIB)/et
LIBEXT2_BLKID := $(LIB)/blkid
LIBGNULIB := $(PARTED)/libgnulib
LIBCHARSET := $(PARTED)/libcharset
LIBICRT := $(PARTED)/libiconv/icrt
LIBICONV := $(PARTED)/libiconv
LIBPARTED := $(PARTED)/libparted
INC_DIR := $(LOCAL_PATH)/../include/e2fsprogs
E2FSPROGS_INCLUDES := \
$(INC_DIR)/misc \
$(INC_DIR)/blkid \
$(INC_DIR)/e2p \
$(INC_DIR)/et \
$(INC_DIR)/ext2fs \
$(INC_DIR)/ss \
$(INC_DIR)/support \
$(INC_DIR)/uuid \
$(INC_DIR)/e2fsck \
$(INC_DIR)
$(INC_DIR)/misc \
$(INC_DIR)/blkid \
$(INC_DIR)/e2p \
$(INC_DIR)/et \
$(INC_DIR)/ext2fs \
$(INC_DIR)/ss \
$(INC_DIR)/support \
$(INC_DIR)/uuid \
$(INC_DIR)/e2fsck \
$(INC_DIR)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2fs
LOCAL_SRC_FILES := \
$(LIBEXT2FS)/ext2_err.c \
$(LIBEXT2FS)/alloc.c \
$(LIBEXT2FS)/alloc_sb.c \
$(LIBEXT2FS)/alloc_stats.c \
$(LIBEXT2FS)/alloc_tables.c \
$(LIBEXT2FS)/atexit.c \
$(LIBEXT2FS)/badblocks.c \
$(LIBEXT2FS)/bb_inode.c \
$(LIBEXT2FS)/bitmaps.c \
$(LIBEXT2FS)/bitops.c \
$(LIBEXT2FS)/blkmap64_ba.c \
$(LIBEXT2FS)/blkmap64_rb.c \
$(LIBEXT2FS)/blknum.c \
$(LIBEXT2FS)/block.c \
$(LIBEXT2FS)/bmap.c \
$(LIBEXT2FS)/check_desc.c \
$(LIBEXT2FS)/crc16.c \
$(LIBEXT2FS)/crc32c.c \
$(LIBEXT2FS)/csum.c \
$(LIBEXT2FS)/closefs.c \
$(LIBEXT2FS)/dblist.c \
$(LIBEXT2FS)/dblist_dir.c \
$(LIBEXT2FS)/digest_encode.c \
$(LIBEXT2FS)/dirblock.c \
$(LIBEXT2FS)/dirhash.c \
$(LIBEXT2FS)/dir_iterate.c \
$(LIBEXT2FS)/dupfs.c \
$(LIBEXT2FS)/expanddir.c \
$(LIBEXT2FS)/ext_attr.c \
$(LIBEXT2FS)/extent.c \
$(LIBEXT2FS)/fallocate.c \
$(LIBEXT2FS)/fileio.c \
$(LIBEXT2FS)/finddev.c \
$(LIBEXT2FS)/flushb.c \
$(LIBEXT2FS)/freefs.c \
$(LIBEXT2FS)/gen_bitmap.c \
$(LIBEXT2FS)/gen_bitmap64.c \
$(LIBEXT2FS)/get_num_dirs.c \
$(LIBEXT2FS)/get_pathname.c \
$(LIBEXT2FS)/getsize.c \
$(LIBEXT2FS)/getsectsize.c \
$(LIBEXT2FS)/hashmap.c \
$(LIBEXT2FS)/i_block.c \
$(LIBEXT2FS)/icount.c \
$(LIBEXT2FS)/imager.c \
$(LIBEXT2FS)/ind_block.c \
$(LIBEXT2FS)/initialize.c \
$(LIBEXT2FS)/inline.c \
$(LIBEXT2FS)/inline_data.c \
$(LIBEXT2FS)/inode.c \
$(LIBEXT2FS)/io_manager.c \
$(LIBEXT2FS)/ismounted.c \
$(LIBEXT2FS)/link.c \
$(LIBEXT2FS)/llseek.c \
$(LIBEXT2FS)/lookup.c \
$(LIBEXT2FS)/mmp.c \
$(LIBEXT2FS)/mkdir.c \
$(LIBEXT2FS)/mkjournal.c \
$(LIBEXT2FS)/namei.c \
$(LIBEXT2FS)/native.c \
$(LIBEXT2FS)/newdir.c \
$(LIBEXT2FS)/nls_utf8.c \
$(LIBEXT2FS)/openfs.c \
$(LIBEXT2FS)/progress.c \
$(LIBEXT2FS)/punch.c \
$(LIBEXT2FS)/qcow2.c \
$(LIBEXT2FS)/rbtree.c \
$(LIBEXT2FS)/read_bb.c \
$(LIBEXT2FS)/read_bb_file.c \
$(LIBEXT2FS)/res_gdt.c \
$(LIBEXT2FS)/rw_bitmaps.c \
$(LIBEXT2FS)/sha256.c \
$(LIBEXT2FS)/sha512.c \
$(LIBEXT2FS)/swapfs.c \
$(LIBEXT2FS)/symlink.c \
$(LIBEXT2FS)/undo_io.c \
$(LIBEXT2FS)/unix_io.c \
$(LIBEXT2FS)/sparse_io.c \
$(LIBEXT2FS)/unlink.c \
$(LIBEXT2FS)/valid_blk.c \
$(LIBEXT2FS)/version.c \
$(LIBEXT2FS)/test_io.c
$(LIBEXT2FS)/ext2_err.c \
$(LIBEXT2FS)/alloc.c \
$(LIBEXT2FS)/alloc_sb.c \
$(LIBEXT2FS)/alloc_stats.c \
$(LIBEXT2FS)/alloc_tables.c \
$(LIBEXT2FS)/atexit.c \
$(LIBEXT2FS)/badblocks.c \
$(LIBEXT2FS)/bb_inode.c \
$(LIBEXT2FS)/bitmaps.c \
$(LIBEXT2FS)/bitops.c \
$(LIBEXT2FS)/blkmap64_ba.c \
$(LIBEXT2FS)/blkmap64_rb.c \
$(LIBEXT2FS)/blknum.c \
$(LIBEXT2FS)/block.c \
$(LIBEXT2FS)/bmap.c \
$(LIBEXT2FS)/check_desc.c \
$(LIBEXT2FS)/crc16.c \
$(LIBEXT2FS)/crc32c.c \
$(LIBEXT2FS)/csum.c \
$(LIBEXT2FS)/closefs.c \
$(LIBEXT2FS)/dblist.c \
$(LIBEXT2FS)/dblist_dir.c \
$(LIBEXT2FS)/digest_encode.c \
$(LIBEXT2FS)/dirblock.c \
$(LIBEXT2FS)/dirhash.c \
$(LIBEXT2FS)/dir_iterate.c \
$(LIBEXT2FS)/dupfs.c \
$(LIBEXT2FS)/expanddir.c \
$(LIBEXT2FS)/ext_attr.c \
$(LIBEXT2FS)/extent.c \
$(LIBEXT2FS)/fallocate.c \
$(LIBEXT2FS)/fileio.c \
$(LIBEXT2FS)/finddev.c \
$(LIBEXT2FS)/flushb.c \
$(LIBEXT2FS)/freefs.c \
$(LIBEXT2FS)/gen_bitmap.c \
$(LIBEXT2FS)/gen_bitmap64.c \
$(LIBEXT2FS)/get_num_dirs.c \
$(LIBEXT2FS)/get_pathname.c \
$(LIBEXT2FS)/getsize.c \
$(LIBEXT2FS)/getsectsize.c \
$(LIBEXT2FS)/hashmap.c \
$(LIBEXT2FS)/i_block.c \
$(LIBEXT2FS)/icount.c \
$(LIBEXT2FS)/imager.c \
$(LIBEXT2FS)/ind_block.c \
$(LIBEXT2FS)/initialize.c \
$(LIBEXT2FS)/inline.c \
$(LIBEXT2FS)/inline_data.c \
$(LIBEXT2FS)/inode.c \
$(LIBEXT2FS)/io_manager.c \
$(LIBEXT2FS)/ismounted.c \
$(LIBEXT2FS)/link.c \
$(LIBEXT2FS)/llseek.c \
$(LIBEXT2FS)/lookup.c \
$(LIBEXT2FS)/mmp.c \
$(LIBEXT2FS)/mkdir.c \
$(LIBEXT2FS)/mkjournal.c \
$(LIBEXT2FS)/namei.c \
$(LIBEXT2FS)/native.c \
$(LIBEXT2FS)/newdir.c \
$(LIBEXT2FS)/nls_utf8.c \
$(LIBEXT2FS)/openfs.c \
$(LIBEXT2FS)/progress.c \
$(LIBEXT2FS)/punch.c \
$(LIBEXT2FS)/qcow2.c \
$(LIBEXT2FS)/rbtree.c \
$(LIBEXT2FS)/read_bb.c \
$(LIBEXT2FS)/read_bb_file.c \
$(LIBEXT2FS)/res_gdt.c \
$(LIBEXT2FS)/rw_bitmaps.c \
$(LIBEXT2FS)/sha256.c \
$(LIBEXT2FS)/sha512.c \
$(LIBEXT2FS)/swapfs.c \
$(LIBEXT2FS)/symlink.c \
$(LIBEXT2FS)/undo_io.c \
$(LIBEXT2FS)/unix_io.c \
$(LIBEXT2FS)/sparse_io.c \
$(LIBEXT2FS)/unlink.c \
$(LIBEXT2FS)/valid_blk.c \
$(LIBEXT2FS)/version.c \
$(LIBEXT2FS)/test_io.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-unused-but-set-variable \
-fPIC \
-pthread
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-unused-but-set-variable \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
@@ -184,27 +169,27 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libext2_blkid
LOCAL_SRC_FILES := \
$(LIBEXT2_BLKID)/cache.c \
$(LIBEXT2_BLKID)/dev.c \
$(LIBEXT2_BLKID)/devname.c \
$(LIBEXT2_BLKID)/devno.c \
$(LIBEXT2_BLKID)/getsize.c \
$(LIBEXT2_BLKID)/llseek.c \
$(LIBEXT2_BLKID)/probe.c \
$(LIBEXT2_BLKID)/read.c \
$(LIBEXT2_BLKID)/resolve.c \
$(LIBEXT2_BLKID)/save.c \
$(LIBEXT2_BLKID)/tag.c \
$(LIBEXT2_BLKID)/version.c
$(LIBEXT2_BLKID)/cache.c \
$(LIBEXT2_BLKID)/dev.c \
$(LIBEXT2_BLKID)/devname.c \
$(LIBEXT2_BLKID)/devno.c \
$(LIBEXT2_BLKID)/getsize.c \
$(LIBEXT2_BLKID)/llseek.c \
$(LIBEXT2_BLKID)/probe.c \
$(LIBEXT2_BLKID)/read.c \
$(LIBEXT2_BLKID)/resolve.c \
$(LIBEXT2_BLKID)/save.c \
$(LIBEXT2_BLKID)/tag.c \
$(LIBEXT2_BLKID)/version.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=attributes \
-Wno-error=pointer-sign \
-Wno-unused-but-set-variable \
-fno-strict-aliasing \
-fPIC \
-pthread
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=attributes \
-Wno-error=pointer-sign \
-Wno-unused-but-set-variable \
-fno-strict-aliasing \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
@@ -212,21 +197,21 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libext2_uuid
LOCAL_SRC_FILES := \
$(LIBEXT2_UUID)/clear.c \
$(LIBEXT2_UUID)/compare.c \
$(LIBEXT2_UUID)/copy.c \
$(LIBEXT2_UUID)/gen_uuid.c \
$(LIBEXT2_UUID)/isnull.c \
$(LIBEXT2_UUID)/pack.c \
$(LIBEXT2_UUID)/parse.c \
$(LIBEXT2_UUID)/unpack.c \
$(LIBEXT2_UUID)/unparse.c \
$(LIBEXT2_UUID)/uuid_time.c
$(LIBEXT2_UUID)/clear.c \
$(LIBEXT2_UUID)/compare.c \
$(LIBEXT2_UUID)/copy.c \
$(LIBEXT2_UUID)/gen_uuid.c \
$(LIBEXT2_UUID)/isnull.c \
$(LIBEXT2_UUID)/pack.c \
$(LIBEXT2_UUID)/parse.c \
$(LIBEXT2_UUID)/unpack.c \
$(LIBEXT2_UUID)/unparse.c \
$(LIBEXT2_UUID)/uuid_time.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
@@ -234,38 +219,38 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libext2_e2p
LOCAL_SRC_FILES := \
$(LIBEXT2_E2P)/crypto_mode.c \
$(LIBEXT2_E2P)/encoding.c \
$(LIBEXT2_E2P)/errcode.c \
$(LIBEXT2_E2P)/feature.c \
$(LIBEXT2_E2P)/fgetflags.c \
$(LIBEXT2_E2P)/fgetproject.c \
$(LIBEXT2_E2P)/fgetversion.c \
$(LIBEXT2_E2P)/fsetflags.c \
$(LIBEXT2_E2P)/fsetproject.c \
$(LIBEXT2_E2P)/fsetversion.c \
$(LIBEXT2_E2P)/getflags.c \
$(LIBEXT2_E2P)/getversion.c \
$(LIBEXT2_E2P)/hashstr.c \
$(LIBEXT2_E2P)/iod.c \
$(LIBEXT2_E2P)/ljs.c \
$(LIBEXT2_E2P)/ls.c \
$(LIBEXT2_E2P)/mntopts.c \
$(LIBEXT2_E2P)/ostype.c \
$(LIBEXT2_E2P)/parse_num.c \
$(LIBEXT2_E2P)/pe.c \
$(LIBEXT2_E2P)/percent.c \
$(LIBEXT2_E2P)/pf.c \
$(LIBEXT2_E2P)/ps.c \
$(LIBEXT2_E2P)/setflags.c \
$(LIBEXT2_E2P)/setversion.c \
$(LIBEXT2_E2P)/uuid.c
$(LIBEXT2_E2P)/crypto_mode.c \
$(LIBEXT2_E2P)/encoding.c \
$(LIBEXT2_E2P)/errcode.c \
$(LIBEXT2_E2P)/feature.c \
$(LIBEXT2_E2P)/fgetflags.c \
$(LIBEXT2_E2P)/fgetproject.c \
$(LIBEXT2_E2P)/fgetversion.c \
$(LIBEXT2_E2P)/fsetflags.c \
$(LIBEXT2_E2P)/fsetproject.c \
$(LIBEXT2_E2P)/fsetversion.c \
$(LIBEXT2_E2P)/getflags.c \
$(LIBEXT2_E2P)/getversion.c \
$(LIBEXT2_E2P)/hashstr.c \
$(LIBEXT2_E2P)/iod.c \
$(LIBEXT2_E2P)/ljs.c \
$(LIBEXT2_E2P)/ls.c \
$(LIBEXT2_E2P)/mntopts.c \
$(LIBEXT2_E2P)/ostype.c \
$(LIBEXT2_E2P)/parse_num.c \
$(LIBEXT2_E2P)/pe.c \
$(LIBEXT2_E2P)/percent.c \
$(LIBEXT2_E2P)/pf.c \
$(LIBEXT2_E2P)/ps.c \
$(LIBEXT2_E2P)/setflags.c \
$(LIBEXT2_E2P)/setversion.c \
$(LIBEXT2_E2P)/uuid.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=attributes \
-fPIC \
-pthread
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=attributes \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
@@ -273,22 +258,22 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libext2_quota
LOCAL_SRC_FILES := \
$(LIBEXT2_QUOTA)/devname.c \
$(LIBEXT2_QUOTA)/dict.c \
$(LIBEXT2_QUOTA)/mkquota.c \
$(LIBEXT2_QUOTA)/parse_qtype.c \
$(LIBEXT2_QUOTA)/plausible.c \
$(LIBEXT2_QUOTA)/prof_err.c \
$(LIBEXT2_QUOTA)/profile.c \
$(LIBEXT2_QUOTA)/profile_helpers.c \
$(LIBEXT2_QUOTA)/quotaio.c \
$(LIBEXT2_QUOTA)/quotaio_tree.c \
$(LIBEXT2_QUOTA)/quotaio_v2.c
$(LIBEXT2_QUOTA)/devname.c \
$(LIBEXT2_QUOTA)/dict.c \
$(LIBEXT2_QUOTA)/mkquota.c \
$(LIBEXT2_QUOTA)/parse_qtype.c \
$(LIBEXT2_QUOTA)/plausible.c \
$(LIBEXT2_QUOTA)/prof_err.c \
$(LIBEXT2_QUOTA)/profile.c \
$(LIBEXT2_QUOTA)/profile_helpers.c \
$(LIBEXT2_QUOTA)/quotaio.c \
$(LIBEXT2_QUOTA)/quotaio_tree.c \
$(LIBEXT2_QUOTA)/quotaio_v2.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
@@ -298,10 +283,10 @@ LOCAL_MODULE := libext2_misc
LOCAL_SRC_FILES := $(LIBEXT2_MISC)/create_inode.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=format-extra-args \
-fPIC \
-pthread
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=format-extra-args \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
@@ -309,75 +294,52 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libext2_com_err
LOCAL_SRC_FILES := \
$(LIBEXT2_COM_ERR)/com_err.c \
$(LIBEXT2_COM_ERR)/com_right.c \
$(LIBEXT2_COM_ERR)/error_message.c \
$(LIBEXT2_COM_ERR)/et_name.c \
$(LIBEXT2_COM_ERR)/init_et.c
$(LIBEXT2_COM_ERR)/com_err.c \
$(LIBEXT2_COM_ERR)/com_right.c \
$(LIBEXT2_COM_ERR)/error_message.c \
$(LIBEXT2_COM_ERR)/et_name.c \
$(LIBEXT2_COM_ERR)/init_et.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(LIBGNULIB)/Android.mk
include $(LIBCHARSET)/Android.mk
include $(LIBICRT)/Android.mk
include $(LIBICONV)/Android.mk
include $(LIBPARTED)/Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := pmt
LOCAL_SRC_FILES := \
$(PMT)/Alternatives.c \
$(PMT)/Debug.cpp \
$(PMT)/Root.cpp \
$(PMT)/PartitionManager.cpp \
$(PMT)/PartitionTool.cpp \
$(PMT)/ListPartitions.cpp \
$(PMT)/Version.cpp \
$(PMT)/GetState.cpp \
$(PMT)/Tools.cpp \
$(PMT)/LanguageTools.cpp \
$(PMT)/Languages.cpp \
$(PMT)/Help.cpp \
$(MKE2FS)/default_profile.c \
$(MKE2FS)/mk_hugefiles.c \
$(MKE2FS)/mke2fs.c \
$(MKE2FS)/util.c \
$(PARTED)/parted/command.c \
$(PARTED)/parted/jsonwrt.c \
$(PARTED)/parted/parted.c \
$(PARTED)/parted/strlist.c \
$(PARTED)/parted/table.c \
$(PARTED)/parted/ui.c \
$(PARTED)/parted/version.c
$(PMT)/Debug.cpp \
$(PMT)/Root.cpp \
$(PMT)/PartitionManager.cpp \
$(PMT)/PartitionTool.cpp \
$(PMT)/ListPartitions.cpp \
$(PMT)/Version.cpp \
$(PMT)/GetState.cpp \
$(PMT)/Tools.cpp \
$(PMT)/LanguageTools.cpp \
$(PMT)/Languages.cpp \
$(PMT)/Help.cpp \
$(MKE2FS)/default_profile.c \
$(MKE2FS)/mk_hugefiles.c \
$(MKE2FS)/mke2fs.c \
$(MKE2FS)/util.c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../include/PartitionManager \
$(LOCAL_PATH)/../include/libgnulib \
$(LOCAL_PATH)/../include/libparted \
$(LOCAL_PATH)/parted/lib
$(E2FSPROGS_INCLUDES)
$(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../include/PartitionManager \
$(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(PMT_CXXFLAGS) \
$(E2FSPROGS_DEFAULT_CFLAGS) \
$(PARTED_DEFAULTS_CFLAGS)
$(PMT_CXXFLAGS) \
$(E2FSPROGS_DEFAULT_CFLAGS)
LOCAL_STATIC_LIBRARIES := \
libext2fs \
libext2_blkid \
libext2_uuid \
libext2_e2p \
libext2_quota \
libext2_misc \
libext2_com_err \
libgnulib \
libparted \
libiconv \
libcharset \
libicrt
libext2fs \
libext2_blkid \
libext2_uuid \
libext2_e2p \
libext2_quota \
libext2_misc \
libext2_com_err
include $(BUILD_EXECUTABLE)

View File

@@ -15,7 +15,7 @@
# limitations under the License.
########
# 3.0.2
# 2.9.6
########
# architecture
@@ -23,7 +23,7 @@ APP_ABI := \
arm64-v8a \
armeabi-v7a
APP_PLATFORM := android-21
APP_PLATFORM := android-29
APP_OPTIM := release
APP_STL := c++_static

View File

@@ -1,127 +0,0 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed 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.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <mntent.h>
#include <malloc.h>
ssize_t getrandom(void* buf, size_t buflen, unsigned int flags) {
if (!buf || buflen == 0) {
errno = EINVAL;
return -1;
}
const char* device = (flags & 1) ? "/dev/random" : "/dev/urandom";
int fd = open(device, O_RDONLY);
if (fd < 0) {
perror("Failed to open random device");
return -1;
}
ssize_t total_read = 0;
while (total_read < (ssize_t)buflen) {
ssize_t bytes_read = read(fd, (char*)buf + total_read, buflen - total_read);
if (bytes_read < 0) {
if (errno == EINTR) continue;
perror("Failed to read random data");
close(fd);
return -1;
}
total_read += bytes_read;
}
close(fd);
return total_read;
}
int getentropy(void* buf, size_t buflen) {
if (!buf || buflen == 0 || buflen > 256) {
errno = EINVAL;
return -1;
}
int fd = open("/dev/urandom", O_RDONLY);
if (fd < 0) {
perror("Failed to open /dev/urandom");
return -1;
}
ssize_t total_read = 0;
while (total_read < (ssize_t)buflen) {
ssize_t bytes_read = read(fd, (char*)buf + total_read, buflen - total_read);
if (bytes_read < 0) {
if (errno == EINTR) continue;
perror("Failed to read random data");
close(fd);
return -1;
}
total_read += bytes_read;
}
close(fd);
return 0;
}
char* _Nullable hasmntopt(const struct mntent* mnt, const char* opt) {
if (!mnt || !opt) return NULL;
char* options = mnt->mnt_opts;
size_t opt_len = strlen(opt);
while (*options) {
char *comma = strchr(options, ',');
size_t len = comma ? (size_t)(comma - options) : strlen(options);
if (len == opt_len && strncmp(options, opt, len) == 0)
return (char*)options;
if (!comma) break;
options = comma + 1;
}
return NULL;
}
void* _Nullable reallocarray(void* ptr, size_t count, size_t size) {
if (count == 0 || size == 0) {
free(ptr);
return NULL;
}
if (count > SIZE_MAX / size) return NULL;
size_t total_size = count * size;
void* new_ptr = realloc(ptr, total_size);
if (new_ptr == NULL) return NULL;
return new_ptr;
}
#ifdef __cplusplus
}
#endif
/* end of code */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,8 +16,8 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_STRINGKEYS 1
#define INC_MAIN_LIBS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
@@ -26,67 +26,67 @@ using namespace PartitionManager;
/* it's prints standart logs */
void PartitionManager::DisplayLog(LogLevel LogPriority, const char* _Nonnull fmt, ...)
{
va_list args;
va_start(args, fmt);
va_list args;
va_start(args, fmt);
if (!Config.SilentEnabled)
{
switch (LogPriority)
{
case LOG_LEVEL_ERROR:
fprintf(stderr, "%s: ", Strings::ExecutingName.c_str());
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_WARN:
fprintf(stdout, "%s: ", Display::UsingDispString->warn);
vfprintf(stdout, fmt, args);
break;
case LOG_LEVEL_FATAL:
fprintf(stderr, "%s: ", Display::UsingDispString->fatal);
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_DEBUG:
vfprintf(stdout, fmt, args);
break;
}
}
if (!Config.SilentEnabled)
{
switch (LogPriority)
{
case LOG_LEVEL_ERROR:
fprintf(stderr, "%s: ", Strings::ExecutingName.c_str());
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_WARN:
fprintf(stdout, "%s: ", Display::UsingDispString->warn);
vfprintf(stdout, fmt, args);
break;
case LOG_LEVEL_FATAL:
fprintf(stderr, "%s: ", Display::UsingDispString->fatal);
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_DEBUG:
vfprintf(stdout, fmt, args);
break;
}
}
if (LogPriority == LOG_LEVEL_ERROR) exit(1);
else if (LogPriority == LOG_LEVEL_FATAL) abort();
if (LogPriority == LOG_LEVEL_ERROR) exit(1);
else if (LogPriority == LOG_LEVEL_FATAL) abort();
va_end(args);
va_end(args);
}
/* it's prints verbose logs */
void PartitionManager::DisplayVerboseLog(LogLevel LogPriority, const char* func, const int& line, const char* _Nonnull fmt, ...)
{
va_list args;
va_start(args, fmt);
va_list args;
va_start(args, fmt);
if (Config.VerboseMode)
{
switch (LogPriority)
{
case LOG_LEVEL_ERROR:
fprintf(stderr, "<E> [%s() Line<%d>]: ", func, line);
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_WARN:
fprintf(stdout, "<W> [%s() Line<%d>]: ", func, line);
vfprintf(stdout, fmt, args);
break;
case LOG_LEVEL_FATAL:
fprintf(stderr, "<F> [%s() Line<%d>]: ", func, line);
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_DEBUG:
fprintf(stdout, "<D> [%s() Line<%d>]: ", func, line);
vfprintf(stdout, fmt, args);
break;
}
}
if (Config.VerboseMode)
{
switch (LogPriority)
{
case LOG_LEVEL_ERROR:
fprintf(stderr, "<E> [%s() Line<%d>]: ", func, line);
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_WARN:
fprintf(stdout, "<W> [%s() Line<%d>]: ", func, line);
vfprintf(stdout, fmt, args);
break;
case LOG_LEVEL_FATAL:
fprintf(stderr, "<F> [%s() Line<%d>]: ", func, line);
vfprintf(stderr, fmt, args);
break;
case LOG_LEVEL_DEBUG:
fprintf(stdout, "<D> [%s() Line<%d>]: ", func, line);
vfprintf(stdout, fmt, args);
break;
}
}
va_end(args);
va_end(args);
}
/**

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,8 +16,8 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_STAT 1
#define INC_MAIN_LIBS
#define INC_STAT
#include <PartitionManager/PartitionManager.h>
@@ -31,22 +31,21 @@
*/
int PartitionManager::GetState(const string& filepath, const string& stype)
{
struct stat GetStat;
VLOGD("Checking `%s' with 'stat <sys/stat.h>'...\n", filepath.c_str());
struct stat GetStat;
VLOGD("Checking `%s' with 'stat <sys/stat.h>'...\n", filepath.c_str());
if (stat(filepath.c_str(), &GetStat) != 0) return 1;
if (stype == "none") return 0;
if (stype == "dir")
return (S_ISDIR(GetStat.st_mode)) ? 0 : -1;
else if (stype == "file")
return (S_ISREG(GetStat.st_mode)) ? 0 : -1;
else if (stype == "blk")
return (S_ISBLK(GetStat.st_mode)) ? 0 : -1;
else if (stype == "link")
return (S_ISLNK(GetStat.st_mode)) ? 0 : -1;
else return 3;
if (stat(filepath.c_str(), &GetStat) != 0) return 1;
if (stype == "dir")
return (S_ISDIR(GetStat.st_mode)) ? 0 : -1;
else if (stype == "file")
return (S_ISREG(GetStat.st_mode)) ? 0 : -1;
else if (stype == "blk")
return (S_ISBLK(GetStat.st_mode)) ? 0 : -1;
else if (stype == "link")
return (S_ISLNK(GetStat.st_mode)) ? 0 : -1;
else return 3;
return 2; /* it's a dummy value */
return 2; /* it's a dummy value */
}
/* end of code */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,9 +16,9 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_STRINGKEYS 1
#define HELP_CPP 1
#define INC_MAIN_LIBS
#define INC_STRINGKEYS
#define HELP
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/HelpFn.h>
@@ -30,46 +30,45 @@ struct langdb_docs* Display::UsingDocDispString = nullptr;
static void
PrepareLangconfDocs(void)
{
if (Strings::CurrentLanguage == "en")
Display::UsingDocDispString = &Display::LangDocEn;
else if (Strings::CurrentLanguage == "tr")
Display::UsingDocDispString = &Display::LangDocTr;
if (Strings::CurrentLanguage == "en")
Display::UsingDocDispString = &Display::LangDocEn;
else if (Strings::CurrentLanguage == "tr")
Display::UsingDocDispString = &Display::LangDocTr;
}
void PartitionManager::DisplayHelp(void)
{
VLOGD("Loading language for help messages... Calling PrepareLangconfDocs() <local function>...\n");
PrepareLangconfDocs();
VLOGD("Printing...\n");
LOGD("%s: %s %s\n", Display::UsingDocDispString->usage_docstr, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l1);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l2);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l3);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l4);
LOGD(" %s: %s %s\n\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l5);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l6);
LOGD(" -l, --logical %s\n", Display::UsingDocDispString->docs_strs_l7);
LOGD(" -P, --search-path %s\n", Display::UsingDocDispString->docs_strs_l8);
LOGD(" -p, --list %s\n", Display::UsingDocDispString->docs_strs_l9);
LOGD(" -s, --silent %s\n", Display::UsingDocDispString->docs_strs_l10);
LOGD(" -f, --force %s\n", Display::UsingDocDispString->docs_strs_l11);
LOGD(" -V, --verbose %s\n", Display::UsingDocDispString->docs_strs_l12);
LOGD(" -S, --set-lang %s\n", Display::UsingDocDispString->docs_strs_l13);
LOGD(" -v, --version %s\n", Display::UsingDocDispString->docs_strs_l14);
LOGD(" --help %s\n\n", Display::UsingDocDispString->docs_strs_l15);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l16);
LOGD(" --only-size %s\n", Display::UsingDocDispString->docs_strs_l17);
LOGD(" --as-byte %s\n", Display::UsingDocDispString->docs_strs_l18);
LOGD(" --as-kilobyte %s\n", Display::UsingDocDispString->docs_strs_l19);
LOGD(" --as-megabyte %s\n", Display::UsingDocDispString->docs_strs_l20);
LOGD(" --as-gigabyte %s\n\n", Display::UsingDocDispString->docs_strs_l21);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l22);
LOGD(" %s backup boot_a -P /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s format system_a ext4 --logical\n", Strings::ExecutingName.c_str());
LOGD(" %s -P /dev/block/platform/bootdevice/by-name --list\n", Strings::ExecutingName.c_str());
LOGD(" %s partition-size boot --as-byte\n", Strings::ExecutingName.c_str());
LOGD(" %s partition-size system --only-size --as-gigabyte --logical\n\n", Strings::ExecutingName.c_str());
LOGD("%s <t.me/ShawkTeam | Topics | pmt>\n", Display::UsingDocDispString->docs_strs_l23);
VLOGD("Loading language for help messages... Calling PrepareLangconfDocs() <local function>...\n");
PrepareLangconfDocs();
VLOGD("Printing...\n");
LOGD("%s: %s %s\n", Display::UsingDocDispString->usage_docstr, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l1);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l2);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l3);
LOGD(" %s: %s %s\n\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l4);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l5);
LOGD(" -l, --logical %s\n", Display::UsingDocDispString->docs_strs_l6);
LOGD(" -P, --search-path %s\n", Display::UsingDocDispString->docs_strs_l7);
LOGD(" -p, --list %s\n", Display::UsingDocDispString->docs_strs_l8);
LOGD(" -s, --silent %s\n", Display::UsingDocDispString->docs_strs_l9);
LOGD(" -f, --force %s\n", Display::UsingDocDispString->docs_strs_l10);
LOGD(" -V, --verbose %s\n", Display::UsingDocDispString->docs_strs_l11);
LOGD(" -S, --set-lang %s\n", Display::UsingDocDispString->docs_strs_l12);
LOGD(" -v, --version %s\n", Display::UsingDocDispString->docs_strs_l13);
LOGD(" --help %s\n\n", Display::UsingDocDispString->docs_strs_l14);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l15);
LOGD(" --only-size %s\n", Display::UsingDocDispString->docs_strs_l16);
LOGD(" --as-byte %s\n", Display::UsingDocDispString->docs_strs_l17);
LOGD(" --as-kilobyte %s\n", Display::UsingDocDispString->docs_strs_l18);
LOGD(" --as-megabyte %s\n", Display::UsingDocDispString->docs_strs_l19);
LOGD(" --as-gigabyte %s\n\n", Display::UsingDocDispString->docs_strs_l20);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l21);
LOGD(" %s backup boot_a -P /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s format system_a ext4 --logical\n", Strings::ExecutingName.c_str());
LOGD(" %s -P /dev/block/platform/bootdevice/by-name --list\n", Strings::ExecutingName.c_str());
LOGD(" %s partition-size boot --as-byte\n", Strings::ExecutingName.c_str());
LOGD(" %s partition-size system --only-size --as-gigabyte --logical\n\n", Strings::ExecutingName.c_str());
LOGD("%s <t.me/ShawkTeam | Topics | pmt>\n", Display::UsingDocDispString->docs_strs_l22);
}
/* end of code */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,13 +16,12 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_DEBUGERS 1
#define INC_STAT 1
#define INC_STRINGKEYS 1
#define INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_STAT
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/LanguageConfigs.h>
using namespace PartitionManager;
@@ -32,147 +31,153 @@ using namespace PartitionManager;
#define PMTLANG_CONF "/sdcard/.pmtlang.conf"
#define PMT_SW_POINT "/sdcard/.pmtlangsw"
static fstream LanguageConfigFile;
static bool LanguageApplied = false;
static int StructSize = static_cast<int>(sizeof(LanguageConfig) / sizeof(LanguageConfig[0]));
struct langdb_general* Display::UsingDispString = nullptr;
static fstream langconf;
string supp_langs[] = {
"en",
"tr",
""
};
static bool
InternalStorageDirFound(void)
{
return (GetState(INTERNAL_STORAGE_DIR, "dir") == 0) ? true : false;
return (GetState(INTERNAL_STORAGE_DIR, "dir") == 0) ? true : false;
}
static inline void
LoadLanguageAs(const string& Name, struct langdb_general* &Language)
static bool
LanguageControl(const string& lang)
{
if (LanguageConfigFile.is_open())
LanguageConfigFile.close();
for (int i = 0; !supp_langs[i].empty(); i++)
{
if (lang == supp_langs[i])
return true;
}
VLOGD("Load language as '%s'...\n", Name.c_str());
Display::UsingDispString = Language;
Strings::CurrentLanguage = Name;
LanguageApplied = true;
}
static inline bool
LanguageIsSupport(const string& Name)
{
for (int i = 0; (i < StructSize && !LanguageConfig[i].Name.empty()); i++)
if (Name == LanguageConfig[i].Name) return true;
return false;
}
static int
IfLanguageIsSupport_Load(const string& Name)
{
for (int i = 0; i < StructSize; i++) {
if (Name == LanguageConfig[i].Name) {
VLOGD("'Name' ('%s') is '%s'.\n", Name.c_str(), LanguageConfig[i].Name.c_str());
LoadLanguageAs(LanguageConfig[i].Name, LanguageConfig[i].LanguageStructure);
return 0;
}
}
return -1;
return false;
}
bool PartitionManager::LoadLanguage(void)
{
string TargetLanguage = "en";
LanguageConfigFile.close();
string lang_fpr = "en";
langconf.close();
VLOGD("Checking install type...\n");
if (GetState(TERMUX_PMT_MANDOC) == 0)
Config.InstalledOnTermux = true;
VLOGD("Checking install type...\n");
if (GetState(TERMUX_PMT_MANDOC) == 0)
Config.InstalledOnTermux = true;
VLOGD("Checking internal storage dir: `%s'\n", INTERNAL_STORAGE_DIR);
if (!InternalStorageDirFound())
LOGE("PartitionManagerLanguageTools: İnternal storage directory (`%s') not found or accessible.\n", INTERNAL_STORAGE_DIR);
VLOGD("Checking internal storage dir: `%s'\n", INTERNAL_STORAGE_DIR);
if (!InternalStorageDirFound())
LOGE("PartitionManagerLanguageTools: İnternal storage directory (`%s') not found or accessible.\n", INTERNAL_STORAGE_DIR);
VLOGD("Trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
LanguageConfigFile.open(PMTLANG_CONF, ios::in | ios::out);
VLOGD("Trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
langconf.open(PMTLANG_CONF, ios::in | ios::out);
VLOGD("Checking status: `%s'...\n", PMTLANG_CONF);
if (!LanguageConfigFile.is_open()) {
LanguageConfigFile.open(PMTLANG_CONF, ios::out | ios::trunc);
VLOGD("Checking status: `%s'...\n", PMTLANG_CONF);
if (!langconf.is_open())
{
langconf.open(PMTLANG_CONF, ios::out | ios::trunc);
VLOGD("Calling SetLanguage()...\n");
SetLanguage(LanguageConfig[0].Name, 1);
LoadLanguageAs(LanguageConfig[0].Name, LanguageConfig[0].LanguageStructure); // english - "en"
VLOGD("Calling SetLanguage()...\n");
SetLanguage("en", 1);
Display::UsingDispString = &Display::LangEn;
Strings::CurrentLanguage = "en";
return true;
} else {
VLOGD("Reading `%s'\n", PMTLANG_CONF);
while (getline(LanguageConfigFile, TargetLanguage))
IfLanguageIsSupport_Load(TargetLanguage);
if (langconf.is_open())
langconf.close();
if (!LanguageApplied) {
VLOGD("Calling SetLanguage()\n");
SetLanguage(LanguageConfig[0].Name, 1);
LoadLanguageAs(LanguageConfig[0].Name, LanguageConfig[0].LanguageStructure); // english - "en"
return true;
}
}
return true;
}
else
{
VLOGD("Reading `%s'\n", PMTLANG_CONF);
while (getline(langconf, lang_fpr))
{
if (lang_fpr == "en")
goto SetEn;
else if (lang_fpr == "tr")
goto SetTr;
else
{
VLOGD("Calling SetLanguage()\n");
SetLanguage("en", 1);
VLOGD("Re-calling LoadLanguage()\n");
PartitionManager::LoadLanguage();
return true;
}
}
if (LanguageApplied) return true;
if (!getline(langconf, lang_fpr))
{
VLOGD("Calling SetLanguage()\n");
SetLanguage("en", 1);
VLOGD("Re-calling LoadLanguage()\n");
PartitionManager::LoadLanguage();
return true;
}
}
return false;
SetEn:
langconf.close();
Display::UsingDispString = &Display::LangEn;
Strings::CurrentLanguage = "en";
VLOGD("Loaded \"en\"\n");
return true;
SetTr:
langconf.close();
Display::UsingDispString = &Display::LangTr;
Strings::CurrentLanguage = "tr";
VLOGD("Loaded \"tr\"\n");
return true;
return false;
}
void PartitionManager::SetLanguage(const string& Language, ushort_t NullConfigState)
void PartitionManager::SetLanguage(const string& lang, ushort_t null_conf_stat)
{
VLOGD("Checking speficed language (from input).\n");
if (!LanguageIsSupport(Language))
LOGE("Unknown language: %s.\n", Language.c_str());
VLOGD("Checking speficed language (from input).\n");
if (!LanguageControl(lang))
LOGE("Unknown language: %s.\n", lang.c_str());
LanguageConfigFile.close();
langconf.close();
VLOGD("Checking internal storage dir: `%s'\n", INTERNAL_STORAGE_DIR);
if (!InternalStorageDirFound())
LOGE("PartitionManagerSetLanguage: Internal storage directory (`%s') not found or accessible.\n", INTERNAL_STORAGE_DIR);
VLOGD("Checking internal storage dir: `%s'\n", INTERNAL_STORAGE_DIR);
if (!InternalStorageDirFound())
LOGE("PartitionManagerSetLanguage: Internal storage directory (`%s') not found or accessible.\n", INTERNAL_STORAGE_DIR);
VLOGD("Trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
LanguageConfigFile.open(PMTLANG_CONF, ios::out | ios::trunc);
VLOGD("Trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
langconf.open(PMTLANG_CONF, ios::out | ios::trunc);
if (!LanguageConfigFile.is_open())
LOGE("PartitionManagerLanguageTools: Cannot open/write config file!!!\n");
if (!langconf.is_open())
LOGE("PartitionManagerLanguageTools: Cannot open/write config file!!!\n");
VLOGD("Write \"%s\" to `%s' with 'std <iostream>'\n", Language.c_str(), PMTLANG_CONF);
LanguageConfigFile << Language;
if (!LanguageConfigFile)
LOGE("PartitionManagerLanguageTools: Couldn't write config!!!\n");
else
LanguageConfigFile.close();
VLOGD("Write \"%s\" to `%s' with 'std <iostream>'\n", lang.c_str(), PMTLANG_CONF);
langconf << lang;
if (!langconf)
LOGE("PartitionManagerLanguageTools: Couldn't write config!!!\n");
else
langconf.close();
if (NullConfigState != 1) {
VLOGD("Generating dummy file `%s' with 'ofstream <fstream>'\n", PMT_SW_POINT);
ofstream sw_point(PMT_SW_POINT, ios::trunc);
if (sw_point.is_open()) sw_point.close();
}
}
void DisplaySupportedLanguages(void)
{
VLOGD("Listing supported languages...\n");
LOGD("List of supported languages: \n");
for (int i = 0; i < StructSize; i++)
LOGD(" - %s (%s)\n",
LanguageConfig[i].ExName,
LanguageConfig[i].Name);
if (null_conf_stat != 1)
{
VLOGD("Generating dummy file `%s' with 'ofstream <fstream>'\n", PMT_SW_POINT);
ofstream sw_point(PMT_SW_POINT, ios::trunc);
if (sw_point.is_open())
sw_point.close();
}
}
bool PartitionManager::CleanSWPoint(void)
{
if (GetState(PMT_SW_POINT) == 0) {
VLOGD("Removing (force) `%s' with 'remove <unistd.h>'\n", PMT_SW_POINT);
remove(PMT_SW_POINT);
return true;
}
if (GetState(PMT_SW_POINT) == 0)
{
VLOGD("Removing (force) `%s' with 'remove <unistd.h>'\n", PMT_SW_POINT);
remove(PMT_SW_POINT);
return true;
}
return false;
return false;
}
/* end of code */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,8 +16,8 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_STRINGKEYS 1
#define INC_MAIN_LIBS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
@@ -25,237 +25,221 @@ namespace PartitionManager {
namespace Display {
struct langdb_general LangEn = {
.lang_by_s = "YZBruh & r0manas",
.language = "English",
.lang_prefix = "en",
.not_logical = "This device does not have logical partitions!",
.not_file = "is not a file.",
.not_dir = "is not a directory.",
.not_in_dev = "Nothing found in /dev. Use force mode to avoid this error.",
.not_open = "Couldn't open",
.not_block = "The specified partition is not recognized as a block device. Use force mode to avoid this error.",
.not_read = "Couldn't read",
.not_readdir = "Couldn't read directory",
.not_write = "Couldn't write",
.not_gen = "Couldn't generate",
.no_root = "Root access could not be detected! Please run this with root permissions.",
.expected_backup_arg = "Expected backup argument 2 (1 of them are not mandatory), retrieved",
.expected_flash_arg = "Expected flash argument 2, retrieved",
.expected_format_arg = "Expected format argument 2, retrieved",
.expected_partsz_arg = "Expected partition-size argument 1, retrieved",
.expected_partutil_arg = "Expected part-util argument 1, retrieved",
.missing_operand = "Missing operand",
.multiple_wiewers = "Multiple viewers can't be used on the same line.",
.symbol_rule = "When specifying arguments for an option, ensure they do not begin with '-'. Each argument must correspond correctly to its respective option.",
.req_part_name = "Partition name required.",
.part_not_found = "Partition not found! Maybe a logical partition?",
.unsupported_fs = "Formatter: unsupported filesystem",
.cannot_stat = "Cannot stat",
.ffile_more_part = "Flash file size exceeds partition capacity. Use force mode to avoid this error (not recommended, riscy!).",
.cannot_get_bsz = "Failed to retrieve partition block size.",
.format_fail = "Formatting failed! There is a possibility of data damage.",
.fail_get_psize = "Cannot get partition size",
.depr_backup_opt = "These options for the backup are unavailable.",
.depr_flash_opt = "These options for the flash are unavailable.",
.depr_format_opt = "These options for the format are unavailable.",
.depr_Vlicense_opt = "Deprecated because it was unnecessary.",
.depr_ch_list_opt = "Use -p argument for listing partitions.",
.depr_ch_sp_opt = "Use -P (--search-path) argument instead of -c (--context).",
.not_spec_opt = "Specify the necessary arguments, not option",
.some_spec = "You may have indicated options, but they don't work much unless you speficy a main transaction",
.logical_warn = "This device uses logical partitions.",
.ab_warn = "This device uses A/B partition style.",
.out_not_spec = "Output file name not specified. Using created name",
.no_found_on_process = "The file that was processed was not found. Something wen wrong...",
.please_rerun = "Please rerun the command.",
.part_disk_sz = "Partition (backup) size",
.flash_file_sz = "Flash file size",
.part_disk_sz_fail = "Failed to retrieve partition disk size.",
.flash_file_sz_fail = "Failed to retrieve flash file size.",
.cannot_find_any_defdevice = "Couldn't find any default device",
.cannot_find_device = "Device not founded",
.found_defdevice = "Founded a default device",
.not_spec_device_on_args = "Device is not speficed in arguments. Searching default devices (by pmt)",
.starting_parted = "Starting parted",
.exited_with = "Exited parted with exit code",
.unknown_opr = "Unknown operand",
.req_an_arg = "option requires an argument",
.list_of_general = "List of general partitions",
.list_of_logc = "List of logical partitions",
.success_backup = "Backup successful. Output",
.success_flash = "Flash successful",
.success_format = "Format successful",
.formatting = "Formatting",
.warn = "WARNING",
.fatal = "FATAL ERROR",
.is_requires_arg = "requires an argument",
.only_partsz_args = "Flags can be used only in partition size view were identified. But target not this",
.unknw_arg = "unknown option",
.switching_lang = "Switching language...",
.welcome = "language!",
.welcome_ = "Welcome to ",
.for_more = "for more information",
.s_and_v = "Silent and verbose mode cannot be used together!",
.try_h = "Try",
.usage_head = "Usage",
.depr_opt_str = "DEPRECATED OPTION",
.switched_opt_str = "SWITCHED OPTION",
.not_changed_opt = "not changed",
.compiler_str = "compiler",
.version_str = "version",
.bin_str = "binary",
.part_name = "Partition name",
.part_type = "Partition is dynamic",
.fs_str = "Filesystem",
.unknw_str = "unknown",
.by_str = "By",
.yes = "true",
.no = "false"
.lang_by_s = "YZBruh & r0manas",
.language = "English",
.lang_prefix = "en",
.not_logical = "This device does not have logical partitions!",
.not_file = "is not a file.",
.not_dir = "is not a directory.",
.not_in_dev = "Nothing found in /dev. Use force mode to avoid this error.",
.not_open = "Couldn't open",
.not_block = "The specified partition is not recognized as a block device. Use force mode to avoid this error.",
.not_read = "Couldn't read",
.not_readdir = "Couldn't read directory",
.not_write = "Couldn't write",
.not_gen = "Couldn't generate",
.no_root = "Root access could not be detected! Please run this with root permissions.",
.expected_backup_arg = "Expected backup argument 2 (1 of them are not mandatory), retrieved",
.expected_flash_arg = "Expected flash argument 2, retrieved",
.expected_format_arg = "Expected format argument 2, retrieved",
.expected_partsz_arg = "Expacted partition-size argument 2, retrieved",
.missing_operand = "Missing operand",
.multiple_wiewers = "Multiple viewers can't be used on the same line.",
.symbol_rule = "When specifying arguments for an option, ensure they do not begin with '-'. Each argument must correspond correctly to its respective option.",
.req_part_name = "Partition name required.",
.part_not_found = "Partition not found! Maybe a logical partition?",
.unsupported_fs = "Formatter: unsupported filesystem",
.cannot_stat = "Cannot stat",
.ffile_more_part = "Flash file size exceeds partition capacity. Use force mode to avoid this error (not recommended, riscy!).",
.cannot_get_bsz = "Failed to retrieve partition block size.",
.format_fail = "Formatting failed! There is a possibility of data damage.",
.fail_get_psize = "Cannot get partition size",
.depr_backup_opt = "These options for the backup are unavailable.",
.depr_flash_opt = "These options for the flash are unavailable.",
.depr_format_opt = "These options for the format are unavailable.",
.depr_Vlicense_opt = "Deprecated because it was unnecessary.",
.depr_ch_list_opt = "Use -p argument for listing partitions.",
.depr_ch_sp_opt = "Use -P (--search-path) argument instead of -c (--context).",
.not_spec_opt = "Specify the necessary arguments, not option",
.some_spec = "You may have indicated options, but they don't work much unless you speficy a main transaction",
.logical_warn = "This device uses logical partitions.",
.ab_warn = "This device uses A/B partition style.",
.out_not_spec = "Output file name not specified. Using created name",
.no_found_on_process = "The file that was processed was not found. Something wen wrong...",
.please_rerun = "Please rerun the command.",
.part_disk_sz = "Partition (backup) size",
.flash_file_sz = "Flash file size",
.part_disk_sz_fail = "Failed to retrieve partition disk size.",
.flash_file_sz_fail = "Failed to retrieve flash file size.",
.unknown_opr = "Unknown operand",
.req_an_arg = "option requires an argument",
.list_of_general = "List of general partitions",
.list_of_logc = "List of logical partitions",
.success_backup = "Backup successful. Output",
.success_flash = "Flash successful",
.success_format = "Format successful",
.formatting = "Formatting",
.warn = "WARNING",
.fatal = "FATAL ERROR",
.is_requires_arg = "requires an argument",
.only_partsz_args = "Flags can be used only in partition size view were identified. But target not this",
.unknw_arg = "unknown option",
.switching_lang = "Switching language...",
.welcome = "language!",
.welcome_ = "Welcome to ",
.for_more = "for more information",
.s_and_v = "Silent and verbose mode cannot be used together!",
.try_h = "Try",
.usage_head = "Usage",
.depr_opt_str = "DEPRECATED OPTION",
.switched_opt_str = "SWITCHED OPTION",
.not_changed_opt = "not changed",
.compiler_str = "compiler",
.version_str = "version",
.bin_str = "binary",
.part_name = "Partition name",
.part_type = "Partition is dynamic",
.fs_str = "Filesystem",
.unknw_str = "unknown",
.by_str = "By",
.yes = "true",
.no = "false"
};
struct langdb_general LangTr = {
.lang_by_s = "YZBruh",
.language = "Türkçe",
.lang_prefix = "tr",
.not_logical = "Bu cihaz mantıksal (logical) bölümlere sahip değil!",
.not_file = "Bu bir dosya değil",
.not_dir = "Bu bir dizin değil",
.not_in_dev = "Bu bir şakamı? Bunun /dev dizini ile bir ilgisi yok (içermiyor). Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.not_open = "ılamıyor",
.not_block = "Belirtilen bölüm bir blok değil. Yani aslında bu bir bölüm bile değil (disk). Bu hatayı almak için şanslı olmak gerek..! Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.not_read = "Veri okunamıyor",
.not_readdir = "Dizin verisi okunamıyor",
.not_write = "Veri yazılamıyor",
.not_gen = "Oluşturulamıyor",
.no_root = "Root erişimi tespit edilemedi! Lütfen root erişimi ile çalıştırın.",
.expected_backup_arg = "Beklenen yedekleme argümanı 2 (bir tanesi zorunlu değil), alınan",
.expected_flash_arg = "Beklenen flaş argümanı 2, alınan",
.expected_format_arg = "Beklenen format argümanı 2, alınan",
.expected_partsz_arg = "Beklenen partition-size argümanı 1, alınan",
.expected_partutil_arg = "Beklenen part-util argümanı 1, alınan",
.missing_operand = "İşlem belirtilmedi",
.multiple_wiewers = "Birden fazla görüntüleme işlemi yapan fonksiyonlar bir arada kullanılamaz. Aynı anda sadece bir tanesi kullanılabilir.",
.symbol_rule = "Bir seçeneğin argümanını verirken argüman önüne '-' sembolü getirilemez. Sembolü kaldırın ve tekrar deneyin.",
.req_part_name = "Bölüm adı gereklidir.",
.part_not_found = "Bölüm bulunamadı! Belki mantıksal (logical) bir bölümdür?",
.unsupported_fs = "Formatlayıcı: desteklenmeyen dosya sistemi:",
.cannot_stat = "Durumu tespit edilemedi",
.ffile_more_part = "Flaşlanacak dosyanın boyutu mevcut bölüm boyutundan fazla. Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın (bunu yapmanız asla önerilmez).",
.cannot_get_bsz = "Bölüm blok boyutu tespit edilemedi!",
.format_fail = "Formatlama başarısız oldu. Bazı şeyler zarar görmüş olabilir!",
.fail_get_psize = "Bölüm boyutu alınamadı",
.depr_backup_opt = "Yedek için artık bu seçeneği kullanamazsınız.",
.depr_flash_opt = "Flaşlama için artık bu seçeneği kullanamazsınız.",
.depr_format_opt = "Formatlama için artıi bu seçeneği kullanamazsınız.",
.depr_Vlicense_opt = "Gereksiz seçeneklere bellek yok!",
.depr_ch_list_opt = "Listeleme için -p seçeneğini kullanabilirsiniz.",
.depr_ch_sp_opt = "Özel arama dizini belirtmek için -P (--search-path) seçeneğini kullanabilirsiniz.",
.logical_warn = "Bu cihaz mantıksal (logical) bölümlere sahip.",
.not_spec_opt = "Seçenek değil, şuan gerekli argümanları verin",
.some_spec = "Seçenek belirtmiş olabilirsiniz fakat, ana işlem belirtmedikçe pek işe yaramazlar",
.ab_warn = "Bu cihazın bazı bölümleri A/B kullanıyor.",
.out_not_spec = "Çıktı dosya adı belirtilmedi. Oluşturulan çıktı adı",
.no_found_on_process = "İşlenmekte olan dosya bulunamadı. Bir şeyler yanlış...",
.please_rerun = "Lütfen yeniden çalıştırın",
.part_disk_sz = "Bölümün (yedek) boyutu",
.flash_file_sz = "Flaşlanacak dosyanın boyutu",
.flash_file_sz_fail = "Uyarı: flaşlanacak dosyanın boyutu tespit edilemedi.",
.part_disk_sz_fail = "Uyarı: bölüm boyutunun boyutu tespit edilemedi.",
.found_defdevice = "Varsayılan bir cihaz bulundu",
.cannot_find_any_defdevice = "Herhangi bir varsayılan cihaz bulunamadı",
.cannot_find_device = "Cihaz bulunamadı",
.not_spec_device_on_args = "Cihaz argümanlarda belirtilmedi. Varsayılan cihazlar aranıyor (pmt tarafından tanımlanan cihazlar)",
.starting_parted = "Parted başlatılıyor",
.exited_with = "Parted çıkış kodu",
.unknown_opr = "Bilinmeyen işlem",
.req_an_arg = "bu seçenek argüman gerektirir",
.list_of_general = "Genel bölümlerin listesi",
.list_of_logc = "Mantıksal (logical) bölümlerin listesi",
.success_backup = "Başarılı. Çıktı",
.success_flash = "Başarılı.",
.success_format = "Formatlama başarılı",
.formatting = "Formatlanıyor",
.warn = "UYARI",
.fatal = "KRİTİK HATA",
.is_requires_arg = "bir argüman gereklidir",
.only_partsz_args = "Sadece bölüm boyutu görüntülemesinde kullanılabilecek bayraklar tespit edildi. Ama hedef bu değil",
.unknw_arg = "bilinmeyen seçenek",
.switching_lang = "Dil değiştiriliyor...",
.welcome = "diline hoş geldiniz!",
.welcome_ = NULL,
.for_more = "komutunu kullanabilirsiniz",
.s_and_v = "Sessiz ve ayrıntılı günlüklenme aynı anda kullanılamaz!",
.try_h = "Daha fazla bilgi",
.usage_head = "Kullanımı",
.depr_opt_str = "KALDIRILMIŞ SEÇENEK",
.switched_opt_str = "DEĞİŞTİRİLMİŞ SEÇENEK",
.not_changed_opt = "değiştirilmedi",
.compiler_str = "derleyicisi",
.version_str = "versiyon",
.bin_str = "yapı",
.part_name = "Bölüm adı",
.part_type = "Dinamik bölüm",
.fs_str = "Dosya sistemi",
.unknw_str = "bilinmeyen",
.by_str = "Çeviriyi yapan(lar):",
.yes = "evet",
.no = "hayır"
.lang_by_s = "YZBruh",
.language = "Türkçe",
.lang_prefix = "tr",
.not_logical = "Bu cihaz mantıksal (logical) bölümlere sahip değil!",
.not_file = "Bu bir dosya değil",
.not_dir = "Bu bir dizin değil",
.not_in_dev = "Bu bir şakamı? Bunun /dev dizini ile bir ilgisi yok (içermiyor). Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.not_open = "ılamıyor",
.not_block = "Belirtilen bölüm bir blok değil. Yani aslında bu bir bölüm bile değil (disk). Bu hatayı almak için şanslı olmak gerek..! Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.not_read = "Veri okunamıyor",
.not_readdir = "Dizin verisi okunamıyor",
.not_write = "Veri yazılamıyor",
.not_gen = "Oluşturulamıyor",
.no_root = "Root erişimi tespit edilemedi! Lütfen root erişimi ile çalıştırın.",
.expected_backup_arg = "Beklenen yedekleme argümanı 2 (bir tanesi zorunlu değil), alınan",
.expected_flash_arg = "Beklenen flaş argümanı 2, alınan",
.expected_format_arg = "Beklenen format argümanı 2, alınan",
.expected_partsz_arg = "Beklenen partition-size argümanı 1, alınan",
.missing_operand = "İşlem belirtilmedi",
.multiple_wiewers = "Birden fazla görüntüleme işlemi yapan fonksiyonlar bir arada kullanılamaz. Aynı anda sadece bir tanesi kullanılabilir.",
.symbol_rule = "Bir seçeneğin argümanını verirken argüman önüne '-' sembolü getirilemez. Sembolü kaldırın ve tekrar deneyin.",
.req_part_name = "Bölüm adı gereklidir.",
.part_not_found = "Bölüm bulunamadı! Belki mantıksal (logical) bir bölümdür?",
.unsupported_fs = "Formatlayıcı: desteklenmeyen dosya sistemi:",
.cannot_stat = "Durumu tespit edilemedi",
.ffile_more_part = "Flaşlanacak dosyanın boyutu mevcut bölüm boyutundan fazla. Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın (bunu yapmanız asla önerilmez).",
.cannot_get_bsz = "Bölüm blok boyutu tespit edilemedi!",
.format_fail = "Formatlama başarısız oldu. Bazı şeyler zarar görmüş olabilir!",
.fail_get_psize = "Bölüm boyutu alınamadı",
.depr_backup_opt = "Yedek için artık bu seçeneği kullanamazsınız.",
.depr_flash_opt = "Flaşlama için artık bu seçeneği kullanamazsınız.",
.depr_format_opt = "Formatlama için artıi bu seçeneği kullanamazsınız.",
.depr_Vlicense_opt = "Gereksiz seçeneklere bellek yok!",
.depr_ch_list_opt = "Listeleme için -p seçeneğini kullanabilirsiniz.",
.depr_ch_sp_opt = "Özel arama dizini belirtmek için -P (--search-path) seçeneğini kullanabilirsiniz.",
.logical_warn = "Bu cihaz mantıksal (logical) bölümlere sahip.",
.not_spec_opt = "Seçenek değil, şuan gerekli argümanları verin",
.some_spec = "Seçenek belirtmiş olabilirsiniz fakat, ana işlem belirtmedikçe pek işe yaramazlar",
.ab_warn = "Bu cihazın bazı bölümleri A/B kullanıyor.",
.out_not_spec = "Çıktı dosya adı belirtilmedi. Oluşturulan çıktı adı",
.no_found_on_process = "İşlenmekte olan dosya bulunamadı. Bir şeyler yanlış...",
.please_rerun = "Lütfen yeniden çalıştırın",
.part_disk_sz = "Bölümün (yedek) boyutu",
.flash_file_sz = "Flaşlanacak dosyanın boyutu",
.flash_file_sz_fail = "Uyarı: flaşlanacak dosyanın boyutu tespit edilemedi.",
.part_disk_sz_fail = "Uyarı: bölüm boyutunun boyutu tespit edilemedi.",
.unknown_opr = "Bilinmeyen işlem",
.req_an_arg = "bu seçenek argüman gerektirir",
.list_of_general = "Genel bölümlerin listesi",
.list_of_logc = "Mantıksal (logical) bölümlerin listesi",
.success_backup = "Başarılı. Çıktı",
.success_flash = "Başarılı.",
.success_format = "Formatlama başarılı",
.formatting = "Formatlanıyor",
.warn = "UYARI",
.fatal = "KRİTİK HATA",
.is_requires_arg = "bir argüman gereklidir",
.only_partsz_args = "Sadece bölüm boyutu görüntülemesinde kullanılabilecek bayraklar tespit edildi. Ama hedef bu değil",
.unknw_arg = "bilinmeyen seçenek",
.switching_lang = "Dil değiştiriliyor...",
.welcome = "diline hoş geldiniz!",
.welcome_ = NULL,
.for_more = "komutunu kullanabilirsiniz",
.s_and_v = "Sessiz ve ayrıntılı günlüklenme aynı anda kullanılamaz!",
.try_h = "Daha fazla bilgi",
.usage_head = "Kullanımı",
.depr_opt_str = "KALDIRILMIŞ SEÇENEK",
.switched_opt_str = "DEĞİŞTİRİLMİŞ SEÇENEK",
.not_changed_opt = "değiştirilmedi",
.compiler_str = "derleyicisi",
.version_str = "versiyon",
.bin_str = "yapı",
.part_name = "Bölüm adı",
.part_type = "Dinamik bölüm",
.fs_str = "Dosya sistemi",
.unknw_str = "bilinmeyen",
.by_str = "Çeviriyi yapan(lar):",
.yes = "evet",
.no = "hayır"
};
struct langdb_docs LangDocEn = {
.docs_strs_l1 = "[OPTIONS] start-parted [DEVICE]...",
.docs_strs_l2 = "[OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...",
.docs_strs_l3 = "[OPTIONS] flash PARTITION FILE [OPTIONS]...",
.docs_strs_l4 = "[OPTIONS] format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...",
.docs_strs_l5 = "[OPTIONS] partition-size PARTITION [OPTIONS]...",
.docs_strs_l6 = "Options",
.docs_strs_l7 = "It is meant to determine whether the target partition is logical.",
.docs_strs_l8 = "It is meant to specify a custom partition search path. Only normal partitions (default: /dev/block/by-name).",
.docs_strs_l9 = "List partitions.",
.docs_strs_l10 = "Information and warning messages are silenced in normal work.",
.docs_strs_l11 = "Force mode. Some things are ignored.",
.docs_strs_l12 = "Verbose mode. Print detailed informations etc.",
.docs_strs_l13 = "Set current language.",
.docs_strs_l14 = "See version.",
.docs_strs_l15 = "See this help message.",
.docs_strs_l16 = "partition-size flags",
.docs_strs_l17 = "Only the size is displayed, the partition name etc is not displayed.",
.docs_strs_l18 = "Display size as byte.",
.docs_strs_l19 = "Display size as kilobyte.",
.docs_strs_l20 = "Display size as megabyte.",
.docs_strs_l21 = "Display size as gigabyte.",
.docs_strs_l22 = "Examples",
.docs_strs_l23 = "Report bugs and suggestions to",
.or_str = "or",
.usage_docstr = "Usage"
.docs_strs_l1 = "[OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...",
.docs_strs_l2 = "[OPTIONS] flash PARTITION FILE [OPTIONS]...",
.docs_strs_l3 = "[OPTIONS] format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...",
.docs_strs_l4 = "[OPTIONS] partition-size PARTITION [OPTIONS]...",
.docs_strs_l5 = "Options",
.docs_strs_l6 = "It is meant to determine whether the target partition is logical.",
.docs_strs_l7 = "It is meant to specify a custom partition search path. Only normal partitions (default: /dev/block/by-name).",
.docs_strs_l8 = "List partitions.",
.docs_strs_l9 = "Information and warning messages are silenced in normal work.",
.docs_strs_l10 = "Force mode. Some things are ignored.",
.docs_strs_l11 = "Verbose mode. Print detailed informations etc.",
.docs_strs_l12 = "Set current language.",
.docs_strs_l13 = "See version.",
.docs_strs_l14 = "See this help message.",
.docs_strs_l15 = "partition-size flags",
.docs_strs_l16 = "Only the size is displayed, the partition name etc is not displayed.",
.docs_strs_l17 = "Display size as byte.",
.docs_strs_l18 = "Display size as kilobyte.",
.docs_strs_l19 = "Display size as megabyte.",
.docs_strs_l20 = "Display size as gigabyte.",
.docs_strs_l21 = "Examples",
.docs_strs_l22 = "Report bugs and suggestions to",
.or_str = "or",
.usage_docstr = "Usage"
};
struct langdb_docs LangDocTr = {
.docs_strs_l1 = "[SEÇENEKLER] start-parted [CİHAZ]...",
.docs_strs_l2 = "[SEÇENEKLER] backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
.docs_strs_l3 = "[SEÇENEKLER] flash BÖLÜM DOSYA [SEÇENEKLER]...",
.docs_strs_l4 = "[SEÇENEKLER] format BÖLÜM DOSYA_SİSTEMİ[ext/2/3/4] [SEÇENEKLER]...",
.docs_strs_l5 = "[SEÇENEKLER] partition-size BÖLÜM [SEÇENEKLER]...",
.docs_strs_l6 = "Seçenekler",
.docs_strs_l7 = "Mantıksal (logical) bölüm ile işlem yapın.",
.docs_strs_l8 = "Özel bir bölüm arama dizini belirtin. Sadece normal bölümler içindir (Varsayılan: /dev/block/by-name).",
.docs_strs_l9 = "Bölümler listelenir.",
.docs_strs_l10 = "Bilgi ve uyarı mesajları susturulur.",
.docs_strs_l11 = "Zorlama modu. Bazı şeyler göz ardı edilir.",
.docs_strs_l12 = "Ayrıntılı bilgi modu. Daha fazla bilgi mesajı verilir.",
.docs_strs_l13 = "Mevcut dili ayarlayın.",
.docs_strs_l14 = "Sürümü görüntüleyin.",
.docs_strs_l15 = "Bu yardım mesajını görüntüleyin.",
.docs_strs_l16 = "partition-size bayrakları",
.docs_strs_l17 = "Boyut görüntülenirken bölüm adı vb gibi bilgiler verilmez, sadece boyut görüntülenir.",
.docs_strs_l18 = "Boyutu bayt olarak görüntüleyin.",
.docs_strs_l19 = "Boyutu kilobayt olarak görüntüleyin.",
.docs_strs_l20 = "Boyutu megabyte olarak görüntüleyin.",
.docs_strs_l21 = "Boyutu gigabayt olarak görüntüleyin.",
.docs_strs_l22 = "Örnekler",
.docs_strs_l23 = "Sorunları ve önerileri şuraya bildirin:",
.or_str = "yada",
.usage_docstr = "Kullanımı"
.docs_strs_l1 = "[SEÇENEKLER] backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
.docs_strs_l2 = "[SEÇENEKLER] flash BÖLÜM DOSYA [SEÇENEKLER]...",
.docs_strs_l3 = "[SEÇENEKLER] format BÖLÜM DOSYA_SİSTEMİ[ext/2/3/4] [SEÇENEKLER]...",
.docs_strs_l4 = "[SEÇENEKLER] partition-size BÖLÜM [SEÇENEKLER]...",
.docs_strs_l5 = "Seçenekler",
.docs_strs_l6 = "Mantıksal (logical) bölüm ile işlem yapın.",
.docs_strs_l7 = "Özel bir bölüm arama dizini belirtin. Sadece normal bölümler içindir (Varsayılan: /dev/block/by-name).",
.docs_strs_l8 = "Bölümler listelenir.",
.docs_strs_l9 = "Bilgi ve uyarı mesajları susturulur.",
.docs_strs_l10 = "Zorlama modu. Bazı şeyler göz ardı edilir.",
.docs_strs_l11 = "Ayrıntılı bilgi modu. Daha fazla bilgi mesajı verilir.",
.docs_strs_l12 = "Mevcut dili ayarlayın.",
.docs_strs_l13 = "Sürümü görüntüleyin.",
.docs_strs_l14 = "Bu yardım mesajını görüntüleyin.",
.docs_strs_l15 = "partition-size bayrakları",
.docs_strs_l16 = "Boyut görüntülenirken bölüm adı vb gibi bilgiler verilmez, sadece boyut görüntülenir.",
.docs_strs_l17 = "Boyutu bayt olarak görüntüleyin.",
.docs_strs_l18 = "Boyutu kilobayt olarak görüntüleyin.",
.docs_strs_l19 = "Boyutu megabyte olarak görüntüleyin.",
.docs_strs_l20 = "Boyutu gigabayt olarak görüntüleyin.",
.docs_strs_l21 = "Örnekler",
.docs_strs_l22 = "Sorunları ve önerileri şuraya bildirin:",
.or_str = "yada",
.usage_docstr = "Kullanımı"
};
} /* namespace Display */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,10 +16,10 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_DEBUGERS 1
#define INC_DIRENT 1
#define INC_STRINGKEYS 1
#define INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_DIRENT
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
@@ -33,108 +33,108 @@ static DIR* Directory;
static int
ListDir(const string& TargetDir, const bool ListTargetDir = false)
{
static int count;
struct dirent **List;
bool ListParts = (ListTargetDir) ? true : false;
static int count;
struct dirent **List;
bool ListParts = (ListTargetDir) ? true : false;
Directory = nullptr;
Directory = opendir(TargetDir.c_str());
Directory = nullptr;
Directory = opendir(TargetDir.c_str());
if (ListParts)
{
count = scandir(TargetDir.c_str(), &List, nullptr, alphasort);
if (ListParts)
{
count = scandir(TargetDir.c_str(), &List, nullptr, alphasort);
if (count < 0)
LOGE("%s: `%s': %s\n",
Display::UsingDispString->not_readdir,
TargetDir.c_str(),
strqerror());
if (count < 0)
LOGE("%s: `%s': %s\n",
Display::UsingDispString->not_readdir,
TargetDir.c_str(),
strqerror());
for (int i = 0; i < count; i++)
{
if (List[i]->d_name[0] != '.'
&& strncmp(List[i]->d_name, "com.", 4) != 0
&& strcmp(List[i]->d_name, "by-uuid") != 0
&& strcmp(List[i]->d_name, "userdata") != 0)
LOGD(" - [ %-16s ]\n", List[i]->d_name);
for (int i = 0; i < count; i++)
{
if (List[i]->d_name[0] != '.'
&& strncmp(List[i]->d_name, "com.", 4) != 0
&& strcmp(List[i]->d_name, "by-uuid") != 0
&& strcmp(List[i]->d_name, "userdata") != 0)
LOGD(" - [ %-16s ]\n", List[i]->d_name);
free(List[i]);
}
free(List[i]);
}
free(List);
List = nullptr;
free(List);
List = nullptr;
goto directory;
}
goto directory;
}
directory:
if (Directory != nullptr)
{
closedir(Directory);
return 0;
}
else
return -1;
if (Directory != nullptr)
{
closedir(Directory);
return 0;
}
else
return -1;
return 2;
return 2;
}
/* list existing partitions */
int PartitionManager::ListPartitions(void)
{
VLOGD("Selecting search path...\n");
string AccessDir = (Config.UseCustomSearchPath) ? Strings::CustomSearchPath : CUR_DEV_SP;
VLOGD("Selecting search path...\n");
string AccessDir = (Config.UseCustomSearchPath) ? Strings::CustomSearchPath : CUR_DEV_SP;
VLOGD("Trying to access `%s'...\n", AccessDir.c_str());
if (ListDir(AccessDir) != 0)
{
if (!Config.ForceMode)
LOGE("%s: `%s': %s\n",
Display::UsingDispString->not_open,
AccessDir.c_str(),
strqerror());
else
return 1;
}
else
{
LOGD("%s:\n", Display::UsingDispString->list_of_general);
ListDir(AccessDir, true);
}
VLOGD("Trying to access `%s'...\n", AccessDir.c_str());
if (ListDir(AccessDir) != 0)
{
if (!Config.ForceMode)
LOGE("%s: `%s': %s\n",
Display::UsingDispString->not_open,
AccessDir.c_str(),
strqerror());
else
return 1;
}
else
{
LOGD("%s:\n", Display::UsingDispString->list_of_general);
ListDir(AccessDir, true);
}
if (Config.UsesLogical)
{
VLOGD("Checking for listing `%s'...\n", LGC_DEV_SP);
if (Config.UsesLogical)
{
VLOGD("Checking for listing `%s'...\n", LGC_DEV_SP);
if (ListDir(LGC_DEV_SP) != 0)
LOGE("%s: `%s': %s\n",
Display::UsingDispString->not_open,
LGC_DEV_SP,
strqerror());
else
{
LOGD("\n%s:\n", Display::UsingDispString->list_of_logc);
ListDir(LGC_DEV_SP, true);
}
}
if (ListDir(LGC_DEV_SP) != 0)
LOGE("%s: `%s': %s\n",
Display::UsingDispString->not_open,
LGC_DEV_SP,
strqerror());
else
{
LOGD("\n%s:\n", Display::UsingDispString->list_of_logc);
ListDir(LGC_DEV_SP, true);
}
}
VLOGD("(if have) warnings are printed...\n");
VLOGD("(if have) warnings are printed...\n");
if (Config.UsesLogical)
{
LOGD("\n");
LOGW("%s\n", Display::UsingDispString->logical_warn);
}
if (Config.UsesLogical)
{
LOGD("\n");
LOGW("%s\n", Display::UsingDispString->logical_warn);
}
if (Config.UsesSlots)
{
if (!Config.UsesLogical)
LOGD("\n");
if (Config.UsesSlots)
{
if (!Config.UsesLogical)
LOGD("\n");
LOGW("%s\n", Display::UsingDispString->ab_warn);
}
LOGW("%s\n", Display::UsingDispString->ab_warn);
}
return 0;
return 0;
}
/* end of code */

View File

@@ -1,137 +0,0 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed 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.
*/
#define INC_MAIN_LIBS 1
#define INC_STRINGKEYS 1
#define INC_DEBUGERS 1
#define INC_PTHREAD 1
/* using by new devices */
#define DEFAULT_DEVICE_NEW "/dev/block/sda"
/* using by old devices */
#define DEFAULT_DEVICE_OLD "/dev/block/mmcblk0"
/**
* These macros will be added/deleted/modified
* according to user feedback.
*/
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/Parted.h>
static bool started = false, o_ended = false;
static int ret = 0;
static pthread_mutex_t plock = PTHREAD_MUTEX_INITIALIZER;
extern "C" void* __start_parted(void* dummy_arg);
extern "C" void* __watch_parted(void* dummy_arg);
bool PartitionManager::SearchDevice(const string& DevicePath)
{
VLOGD("Check '%s'.\n", DevicePath.c_str());
if (PartitionManager::GetState(DevicePath, "none") != 0) {
VLOGD("Cannot find '%s'.\n", DevicePath.c_str());
return false;
} else VLOGD("Founded: '%s'.\n", DevicePath.c_str());
return true;
}
bool PartitionManager::SearchDefaultDevices(void)
{
VLOGD("Searching '%s'.\n", DEFAULT_DEVICE_NEW);
if (PartitionManager::SearchDevice(DEFAULT_DEVICE_NEW)) {
PartitionManager::Strings::Device = DEFAULT_DEVICE_NEW;
return true;
}
VLOGD("Searching '%s'.\n", DEFAULT_DEVICE_NEW);
if (PartitionManager::SearchDevice(DEFAULT_DEVICE_OLD)) {
PartitionManager::Strings::Device = DEFAULT_DEVICE_OLD;
return true;
}
return false;
}
void* __watch_parted(void* dummy_arg)
{
while (1) {
pthread_mutex_lock(&plock);
if (started) {
if (o_ended) {
pthread_mutex_unlock(&plock);
return NULL;
}
if (set_ret) {
LOGD("%s: %d.\n",
PartitionManager::Display::UsingDispString->exited_with,
parted_ret);
pthread_mutex_unlock(&plock);
return NULL;
}
} else {
VLOGD("Parted is still not started...\n");
sleep(1);
}
pthread_mutex_unlock(&plock);
usleep(1000);
}
}
void* __start_parted(void* dummy_arg)
{
VLOGD("Generating arguments...\n");
char* arguments[] = {
"parted-pmt",
(char*)PartitionManager::Strings::Device.c_str(),
};
LOGD("%s...\n", PartitionManager::Display::UsingDispString->starting_parted);
VLOGD("Calling parted_main...\n");
pthread_mutex_lock(&plock);
started = true;
pthread_mutex_unlock(&plock);
ret = parted_main(2, arguments);
pthread_mutex_lock(&plock);
o_ended = true;
pthread_mutex_unlock(&plock);
sleep(1);
return NULL;
}
int PartitionManager::StartParted(void)
{
pthread_t t1, t2;
pthread_create(&t1, NULL, __start_parted, NULL);
pthread_create(&t2, NULL, __watch_parted, NULL);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
return ret;
}
/* end of code */

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,7 +16,7 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_MAIN_LIBS
#include <PartitionManager/PartitionManager.h>
#include <sys/system_properties.h>
@@ -24,51 +24,51 @@
static int
GetProperty(const char* _Nonnull property, const char* _Nonnull val1, const char* _Nullable val2 = nullptr)
{
char val[PROP_VALUE_MAX];
int len = __system_property_get(property, val);
char val[PROP_VALUE_MAX];
int len = __system_property_get(property, val);
VLOGD("Get property value: '%s'\n", property);
if (len > 0)
{
VLOGD("%s=%s\n", property, val);
VLOGD("Get property value: '%s'\n", property);
if (len > 0)
{
VLOGD("%s=%s\n", property, val);
VLOGD("Comparing '%s' property value '%s'\n", property, val1);
if (strcmp(val, val1) == 0)
{
VLOGD("'%s' is '%s'. Stop (0).\n", property, val1);
return 0;
}
else
{
VLOGE("'%s' property is not '%s'. Comparing desired value 2 (if speficed).\n", property, val1);
VLOGD("Comparing '%s' property value '%s'\n", property, val1);
if (strcmp(val, val1) == 0)
{
VLOGD("'%s' is '%s'. Stop (0).\n", property, val1);
return 0;
}
else
{
VLOGE("'%s' property is not '%s'. Comparing desired value 2 (if speficed).\n", property, val1);
if (val2 != nullptr)
{
if (strcmp(val, val2) == 0)
{
VLOGD("'%s' is '%s'.Stop (0).\n", property, val2);
return 0;
}
else
{
VLOGE("'%s' is not '%s'. Stop (1).\n", property, val2);
return 1;
}
}
else
{
VLOGE("'%s' is not '%s'. Stop (1).\n", property, val1);
return 1;
}
}
}
else
{
VLOGE("Cannot get property '%s'. No such property or empty. Stop (1).\n", property);
return 1;
}
if (val2 != nullptr)
{
if (strcmp(val, val2) == 0)
{
VLOGD("'%s' is '%s'.Stop (0).\n", property, val2);
return 0;
}
else
{
VLOGE("'%s' is not '%s'. Stop (1).\n", property, val2);
return 1;
}
}
else
{
VLOGE("'%s' is not '%s'. Stop (1).\n", property, val1);
return 1;
}
}
}
else
{
VLOGE("Cannot get property '%s'. No such property or empty. Stop (1).\n", property);
return 1;
}
return 2;
return 2;
}
using namespace PartitionManager;
@@ -76,17 +76,17 @@ using namespace PartitionManager;
/* check parts */
void PartitionManager::CheckDevPoint(void)
{
/* true = ab | false = a only */
Config.UsesSlots = (GetProperty("ro.boot.slot_suffix", "_a", "_b") == 0 || GetProperty("ro.boot.slot", "_a", "_b") == 0) ? true : false;
/* true = ab | false = a only */
Config.UsesSlots = (GetProperty("ro.boot.slot_suffix", "_a", "_b") == 0 || GetProperty("ro.boot.slot", "_a", "_b") == 0) ? true : false;
if (Config.UsesSlots)
VLOGW("1 warning generated: A/B partitions status.\n");
if (Config.UsesSlots)
VLOGW("1 warning generated: A/B partitions status.\n");
/* true = logical | false = normal */
Config.UsesLogical = (GetProperty("ro.boot.dynamic_partitions", "true") == 0) ? true : false;
/* true = logical | false = normal */
Config.UsesLogical = (GetProperty("ro.boot.dynamic_partitions", "true") == 0) ? true : false;
if (Config.UsesLogical)
VLOGW("1 warning generated: logical partitions status.\n");
if (Config.UsesLogical)
VLOGW("1 warning generated: logical partitions status.\n");
}
/* end of code */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,22 +16,22 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_DEBUGERS 1
#define INC_STRINGKEYS 1
#define INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
/* root checker function */
void PartitionManager::CheckRoot(void)
{
VLOGD("Trying to get UID with 'getuid <unistd.h>'\n");
VLOGD("Trying to get UID with 'getuid <unistd.h>'\n");
if (getuid() != 0)
{
VLOGE("You are not superuser!\n");
LOGE("%s\n", PartitionManager::Display::UsingDispString->no_root);
}
if (getuid() != 0)
{
VLOGE("You are not superuser!\n");
LOGE("%s\n", PartitionManager::Display::UsingDispString->no_root);
}
}
/* end of code */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,12 +16,12 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_STAT 1
#define INC_LIBGEN 1
#define INC_DEBUGERS 1
#define INC_TOOLS_REQS 1
#define INC_STRINGKEYS 1
#define INC_MAIN_LIBS
#define INC_STAT
#define INC_LIBGEN
#define INC_DEBUGERS
#define INC_TOOLS_REQS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/PartSizeMacros.h>
@@ -36,69 +36,70 @@ namespace PartitionManager {
* it is meant to calculate the size of the quickly given file.
* its purpose is for rapid processing
*/
static inline long long
static long long
CalculateSizeLongLong(const string& fp)
{
VLOGD("Calculating file size: `%s'\n", fp.c_str());
VLOGD("Calculating file size: `%s'\n", fp.c_str());
VLOGD("Reading `%s' with 'ifstream <fstream>'\n", fp.c_str());
ifstream file(fp, ios::binary | ios::ate);
VLOGD("Reading `%s' with 'ifstream <fstream>'\n", fp.c_str());
ifstream file(fp, ios::binary | ios::ate);
return (!file) ? -1 : static_cast<long long>(file.tellg());
return (!file) ? -1 : static_cast<long long>(file.tellg());
}
/**
* error that the partition is not found.
* It's for quick action.
*/
static inline void
static void
PartitionNotFound(const string& part) { LOGE("%s: %s\n", part.c_str(), Display::UsingDispString->part_not_found); }
/* the partitions are meant to quickly find. */
static inline void
static void
SearchPartition(const string& fp)
{
VLOGD("Calling GetState()...\n");
static int op = GetState(fp, "blk");
VLOGD("Calling GetState()...\n");
static int op = GetState(fp, "blk");
if (op == 1)
PartitionNotFound(basename(fp.c_str()));
else if (op == -1 && !Config.ForceMode)
LOGE("%s\n", Display::UsingDispString->not_block);
if (op == 1)
PartitionNotFound(basename(fp.c_str()));
else if (op == -1 && !Config.ForceMode)
LOGE("%s\n", Display::UsingDispString->not_block);
}
static void
PrintInfo(const ushort_t& pcode, const double& psz, const double& fsz)
{
LOGD("##########################################\n");
LOGD("# --> %s: %s\n",
Display::UsingDispString->part_name,
Strings::TargetPartition.c_str());
LOGD("# --> %s: %s\n",
Display::UsingDispString->part_type,
(Config.UseLogical) ? Display::UsingDispString->yes : Display::UsingDispString->no);
LOGD("##########################################\n");
LOGD("# --> %s: %s\n",
Display::UsingDispString->part_name,
Strings::TargetPartition.c_str());
LOGD("# --> %s: %s\n",
Display::UsingDispString->part_type,
(Config.UseLogical) ? Display::UsingDispString->yes : Display::UsingDispString->no);
if (psz != -1)
LOGD("# --> %s: %.2fMB\n",
Display::UsingDispString->part_disk_sz,
psz);
else
LOGD("# --> %s: %s\n",
Display::UsingDispString->warn,
Display::UsingDispString->part_disk_sz_fail);
if (psz != -1)
LOGD("# --> %s: %.2fMB\n",
Display::UsingDispString->part_disk_sz,
psz);
else
LOGD("# --> %s: %s\n",
Display::UsingDispString->warn,
Display::UsingDispString->part_disk_sz_fail);
if (pcode == 3) {
if (fsz != -1)
LOGD("# --> %s: %.2fMB\n",
Display::UsingDispString->flash_file_sz,
fsz);
else
LOGW("# --> %s: %s\n",
Display::UsingDispString->warn,
Display::UsingDispString->flash_file_sz_fail);
}
if (pcode == 3)
{
if (fsz != -1)
LOGD("# --> %s: %.2fMB\n",
Display::UsingDispString->flash_file_sz,
fsz);
else
LOGW("# --> %s: %s\n",
Display::UsingDispString->warn,
Display::UsingDispString->flash_file_sz_fail);
}
LOGD("##########################################\n");
LOGD("##########################################\n");
}
template <typename T>
@@ -108,47 +109,48 @@ IsDoubleOf1024(T size) { return size % (T)1024 == 0; }
static void
ReadAndWrite(const string& FNameForMsg, const int& bfsize)
{
long long copiedData = 0;
char buffer[bfsize];
long long copiedData = 0;
char buffer[bfsize];
while (sourceF.read(buffer, bfsize) && copiedData < Count) {
streamsize readed_data = sourceF.gcount();
targetF.write(buffer, readed_data);
while (sourceF.read(buffer, bfsize) && copiedData < Count)
{
streamsize readed_data = sourceF.gcount();
targetF.write(buffer, readed_data);
if (targetF.fail() || targetF.bad())
LOGF("%s: %s: %s\n",
Display::UsingDispString->not_write,
FNameForMsg.c_str(),
strqerror());
if (targetF.fail() || targetF.bad())
LOGF("%s: %s: %s\n",
Display::UsingDispString->not_write,
FNameForMsg.c_str(),
strqerror());
copiedData += readed_data;
}
copiedData += readed_data;
}
}
static void
OpenSourceFile(const string& fp)
{
VLOGD("Trying to open `%s' with 'open <fstream>'.\n", fp.c_str());
VLOGD("Trying to open `%s' with 'open <fstream>'.\n", fp.c_str());
sourceF.open(fp, ios::binary | ios::in);
if (!sourceF.is_open())
LOGE("%s: %s: %s\n",
Display::UsingDispString->not_read,
fp.c_str(),
strqerror());
sourceF.open(fp, ios::binary | ios::in);
if (!sourceF.is_open())
LOGE("%s: %s: %s\n",
Display::UsingDispString->not_read,
fp.c_str(),
strqerror());
}
static void
OpenTargetFile(const string& fp)
{
VLOGD("Trying to open `%s' with 'open <fstream>'.\n", fp.c_str());
VLOGD("Trying to open `%s' with 'open <fstream>'.\n", fp.c_str());
targetF.open(fp, ios::binary | ios::out);
if (!targetF.is_open())
LOGE("%s: %s: %s\n",
Display::UsingDispString->not_gen,
fp.c_str(),
strqerror());
targetF.open(fp, ios::binary | ios::out);
if (!targetF.is_open())
LOGE("%s: %s: %s\n",
Display::UsingDispString->not_gen,
fp.c_str(),
strqerror());
}
} /* namespace PartitionManager */
@@ -157,159 +159,172 @@ using namespace PartitionManager;
int PartitionManager::PartitionManagerMain(const ushort_t& progress_code)
{
/* Some required variables */
string accessPrefix, opName;
/* Some required variables */
string accessPrefix, opName;
if (Config.UseLogical)
accessPrefix = "/dev/block/mapper/" + Strings::TargetPartition;
else
accessPrefix = (Config.UseCustomSearchPath) ? (Strings::CustomSearchPath) + ("/") + (Strings::TargetPartition) : ("/dev/block/by-name/") + (Strings::TargetPartition);
if (Config.UseLogical)
accessPrefix = "/dev/block/mapper/" + Strings::TargetPartition;
else
accessPrefix = (Config.UseCustomSearchPath) ? (Strings::CustomSearchPath) + ("/") + (Strings::TargetPartition) : ("/dev/block/by-name/") + (Strings::TargetPartition);
VLOGD("Calling SearchPartition() for searching partition (path); `%s'\n", accessPrefix.c_str());
SearchPartition(accessPrefix);
VLOGD("Calling SearchPartition() for searching partition (path); `%s'\n", accessPrefix.c_str());
SearchPartition(accessPrefix);
Count = (long long)(CalculateSizeLongLong(accessPrefix) + ((1024 * 1024) * 4));
const int BFSIZE = (IsDoubleOf1024(CalculateSizeLongLong(accessPrefix))) ? 1024 : 1;
double FlashFileSize = 0;
Count = (long long)(CalculateSizeLongLong(accessPrefix) + ((1024 * 1024) * 4));
const int BFSIZE = (IsDoubleOf1024(CalculateSizeLongLong(accessPrefix))) ? 1024 : 1;
double FlashFileSize = 0;
double PartitionSize = (double)(static_cast<double>(CalculateSizeLongLong(accessPrefix)) / (1024 * 1024));
if (!Strings::TargetFlashFile.empty())
FlashFileSize = (double)(static_cast<double>(CalculateSizeLongLong(Strings::TargetFlashFile)) / (1024 * 1024));
double PartitionSize = (double)(static_cast<double>(CalculateSizeLongLong(accessPrefix)) / (1024 * 1024));
if (!Strings::TargetFlashFile.empty())
FlashFileSize = (double)(static_cast<double>(CalculateSizeLongLong(Strings::TargetFlashFile)) / (1024 * 1024));
if (progress_code != 4) PrintInfo(progress_code, PartitionSize, FlashFileSize);
if (progress_code != 4) PrintInfo(progress_code, PartitionSize, FlashFileSize);
if (progress_code == 1) {
OpenSourceFile(accessPrefix);
if (progress_code == 1)
{
OpenSourceFile(accessPrefix);
/* determine output */
if (Strings::OutputName == Strings::TargetPartition) {
opName = Strings::OutputName + ".img";
VLOGW("Output not speficed. Selecting automaticly.\n");
LOGW("%s: %s\n",
Display::UsingDispString->out_not_spec,
opName.c_str());
} else
opName = Strings::OutputName;
/* determine output */
if (Strings::OutputName == Strings::TargetPartition)
{
opName = Strings::OutputName + ".img";
VLOGW("Output not speficed. Selecting automaticly.\n");
LOGW("%s: %s\n",
Display::UsingDispString->out_not_spec,
opName.c_str());
}
else
opName = Strings::OutputName;
VLOGD("Checking output status...\n");
if (GetState(opName) == 0)
LOGE("'%s': File exits.\n", opName.c_str());
VLOGD("Checking output status...\n");
if (GetState(opName) == 0)
LOGE("'%s': File exits.\n", opName.c_str());
OpenTargetFile(opName);
OpenTargetFile(opName);
VLOGD("Read (partition) and write (output) 'read, write <fstream>'\n");
ReadAndWrite(opName.c_str(), BFSIZE);
VLOGD("Read (partition) and write (output) 'read, write <fstream>'\n");
ReadAndWrite(opName.c_str(), BFSIZE);
/* close files */
sourceF.close();
targetF.close();
/* close files */
sourceF.close();
targetF.close();
LOGD("%s: %s\n",
Display::UsingDispString->success_backup,
opName.c_str());
} else if (progress_code == 2) {
if (PartitionSize != -1 && FlashFileSize != -1) {
if (FlashFileSize > PartitionSize && !Config.ForceMode)
LOGE("%s\n", Display::UsingDispString->ffile_more_part);
}
LOGD("%s: %s\n",
Display::UsingDispString->success_backup,
opName.c_str());
}
else if (progress_code == 2)
{
if (PartitionSize != -1 && FlashFileSize != -1)
{
if (FlashFileSize > PartitionSize && !Config.ForceMode)
LOGE("%s\n", Display::UsingDispString->ffile_more_part);
}
OpenSourceFile(Strings::TargetFlashFile);
OpenTargetFile(accessPrefix);
OpenSourceFile(Strings::TargetFlashFile);
OpenTargetFile(accessPrefix);
VLOGD("Read (flash file) and write (partition) 'read, write <fstream>'\n");
ReadAndWrite(accessPrefix.c_str(), BFSIZE);
VLOGD("Read (flash file) and write (partition) 'read, write <fstream>'\n");
ReadAndWrite(accessPrefix.c_str(), BFSIZE);
sourceF.close();
targetF.close();
sourceF.close();
targetF.close();
LOGD("%s.\n", Display::UsingDispString->success_flash);
} else if (progress_code == 3) {
/* get target partition block size */
VLOGD("Getting block size '%s' with 'statfs <sys/vfs.h>'\n", accessPrefix.c_str());
LOGD("%s.\n", Display::UsingDispString->success_flash);
}
else if (progress_code == 3)
{
/* get target partition block size */
VLOGD("Getting block size '%s' with 'statfs <sys/vfs.h>'\n", accessPrefix.c_str());
struct statfs file_sys_inf;
if (statfs(accessPrefix.c_str(), &file_sys_inf) != 0)
LOGE("%s\n", Display::UsingDispString->cannot_get_bsz);
struct statfs file_sys_inf;
if (statfs(accessPrefix.c_str(), &file_sys_inf) != 0)
LOGE("%s\n", Display::UsingDispString->cannot_get_bsz);
/* generate mke2fs argument list */
VLOGD("Generating mke2fs argument list...\n");
char bsize[25] = "";
/* generate mke2fs argument list */
VLOGD("Generating mke2fs argument list...\n");
char bsize[25] = "";
#ifdef __LP64__
sprintf(bsize, "%lu", file_sys_inf.f_bsize);
sprintf(bsize, "%lu", file_sys_inf.f_bsize);
#else
sprintf(bsize, "%u", file_sys_inf.f_bsize);
sprintf(bsize, "%u", file_sys_inf.f_bsize);
#endif
char* arguments[] = {
"mke2fs-static",
"-Fq",
"-t",
(char*)Strings::TargetFormatFS.c_str(),
"-b",
(char*)bsize,
(char*)accessPrefix.c_str(),
};
char* arguments[] = {
"mke2fs-static",
"-Fq",
"-t",
(char*)Strings::TargetFormatFS.c_str(),
"-b",
(char*)bsize,
(char*)accessPrefix.c_str(),
};
LOGD("%s: `%s'. %s: %s\n",
Display::UsingDispString->formatting,
accessPrefix.c_str(),
Display::UsingDispString->fs_str,
Strings::TargetFormatFS.c_str());
LOGD("%s: `%s'. %s: %s\n",
Display::UsingDispString->formatting,
accessPrefix.c_str(),
Display::UsingDispString->fs_str,
Strings::TargetFormatFS.c_str());
/* run mke2fs */
VLOGD("Calling mke2fs_main...\n");
if (mke2fs_main(sizeof(arguments), arguments) != 0)
LOGF("%s\n", Display::UsingDispString->format_fail);
/* run mke2fs */
VLOGD("Calling mke2fs_main...\n");
if (mke2fs_main(sizeof(arguments), arguments) != 0)
LOGF("%s\n", Display::UsingDispString->format_fail);
LOGD("%s.\n", Display::UsingDispString->success_format);
} else if (progress_code == 4) {
VLOGD("Getting size of '%s' (long long)\n", accessPrefix.c_str());
long long psize = (long long)CalculateSizeLongLong(accessPrefix);
LOGD("%s.\n", Display::UsingDispString->success_format);
}
else if (progress_code == 4)
{
VLOGD("Getting size of '%s' (long long)\n", accessPrefix.c_str());
long long psize = (long long)CalculateSizeLongLong(accessPrefix);
if (psize == -1) {
VLOGE("Cannot get partition size!\n");
LOGE("%s: %s\n",
Display::UsingDispString->fail_get_psize,
strqerror());
}
if (psize == -1)
{
VLOGE("Cannot get partition size!\n");
LOGE("%s: %s\n",
Display::UsingDispString->fail_get_psize,
strqerror());
}
static char* SizeType;
static char Holder[50];
static char* SizeType;
static char Holder[50];
if (!Config.OnlyViewSize) {
sprintf(Holder, "%s: ", Strings::TargetPartition.c_str());
if (!Config.OnlyViewSize)
{
sprintf(Holder, "%s: ", Strings::TargetPartition.c_str());
if (Integers::PartSizeViewType == VIEW_AS_BYTE) SizeType = "B";
else if (Integers::PartSizeViewType == VIEW_AS_KIB) SizeType = "KB";
else if (Integers::PartSizeViewType == VIEW_AS_MIB) SizeType = "MB";
else if (Integers::PartSizeViewType == VIEW_AS_GIB) SizeType = "GB";
} else
SizeType = "";
if (Integers::PartSizeViewType == VIEW_AS_BYTE) SizeType = "B";
else if (Integers::PartSizeViewType == VIEW_AS_KIB) SizeType = "KB";
else if (Integers::PartSizeViewType == VIEW_AS_MIB) SizeType = "MB";
else if (Integers::PartSizeViewType == VIEW_AS_GIB) SizeType = "GB";
}
else
SizeType = "";
VLOGD("Displaying partition size...\n");
VLOGD("Displaying partition size...\n");
if (Integers::PartSizeViewType == VIEW_AS_BYTE)
LOGD("%s%llu%s\n",
Holder,
(long long)psize,
SizeType);
else if (Integers::PartSizeViewType == VIEW_AS_KIB)
LOGD("%s%lu%s\n",
Holder,
(long)(psize / 1024),
SizeType);
else if (Integers::PartSizeViewType == VIEW_AS_MIB)
LOGD("%s%.2f%s\n",
Holder,
(double)(static_cast<double>(psize) / (1024 * 1024)),
SizeType);
else if (Integers::PartSizeViewType == VIEW_AS_GIB)
LOGD("%s%.2f%s\n",
Holder,
(double)(static_cast<double>(psize) / (1024 * 1024 * 1024)),
SizeType);
}
if (Integers::PartSizeViewType == VIEW_AS_BYTE)
LOGD("%s%llu%s\n",
Holder,
(long long)psize,
SizeType);
else if (Integers::PartSizeViewType == VIEW_AS_KIB)
LOGD("%s%lu%s\n",
Holder,
(long)(psize / 1024),
SizeType);
else if (Integers::PartSizeViewType == VIEW_AS_MIB)
LOGD("%s%.2f%s\n",
Holder,
(double)(static_cast<double>(psize) / (1024 * 1024)),
SizeType);
else if (Integers::PartSizeViewType == VIEW_AS_GIB)
LOGD("%s%.2f%s\n",
Holder,
(double)(static_cast<double>(psize) / (1024 * 1024 * 1024)),
SizeType);
}
return 0;
return 0;
}
/* end of code */

View File

@@ -7,7 +7,7 @@
* 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
* 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,
@@ -16,9 +16,9 @@
* limitations under the License.
*/
#define INC_MAIN_LIBS 1
#define INC_STRINGKEYS 1
#define VERSION_CPP 1
#define INC_MAIN_LIBS
#define INC_STRINGKEYS
#define VERSIONING
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/VersionFnVars.h>
@@ -27,34 +27,33 @@ using namespace PartitionManager;
void PartitionManager::DisplayVersion(void)
{
VLOGD("Printing main info...\n");
LOGD("%s %s %d.%d.%d (%d%d%d / C++) ",
Strings::ExecutingName.c_str(),
Display::UsingDispString->version_str,
PMT_MAJOR,
PMT_MINOR,
PMT_PATCHLEVEL,
PMT_MAJOR,
PMT_MINOR,
PMT_PATCHLEVEL);
VLOGD("Printing main info...\n");
LOGD("%s %s %d.%d.%d (%d%d%d / C++) ",
Strings::ExecutingName.c_str(),
Display::UsingDispString->version_str,
PMT_MAJOR,
PMT_MINOR,
PMT_PATCHLEVEL,
PMT_MAJOR,
PMT_MINOR,
PMT_PATCHLEVEL);
#ifdef __LP64__
LOGD("64-bit %s\n", Display::UsingDispString->bin_str);
LOGD("64-bit %s\n", Display::UsingDispString->bin_str);
#else
LOGD("32-bit %s\n", Display::UsingDispString->bin_str);
LOGD("32-bit %s\n", Display::UsingDispString->bin_str);
#endif
LOGD("mke2fs %s %s (%s)\n",
Display::UsingDispString->version_str,
E2FSPROGS_VERSION_PRIVATE,
E2FSPROGS_DATE);
LOGD("libext2fs %s %s (%s / %s)\n",
Display::UsingDispString->version_str,
E2FSPROGS_VERSION_PRIVATE,
EXT2FS_LIB_VERSION_PRIVATE,
E2FSPROGS_DATE);
LOGD("\n%s\n", __NDK_CXX_VERSION__);
LOGD("mke2fs %s %s (%s)\n",
Display::UsingDispString->version_str,
E2FSPROGS_VERSION_PRIVATE,
E2FSPROGS_DATE);
LOGD("libext2fs %s %s (%s / %s)\n",
Display::UsingDispString->version_str,
E2FSPROGS_VERSION_PRIVATE,
EXT2FS_LIB_VERSION_PRIVATE,
E2FSPROGS_DATE);
LOGD("\n%s\n", __NDK_CXX_VERSION__);
}
/* end of code */

View File

@@ -1,382 +0,0 @@
# By YZBruh
# Copyright 2024 Partition Manager
#
# Licensed 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.
#####
# sub-make for building e2fsprogs (built-in mke2fs)
#####
# Include required files
include ../../build/config/env.mk
ifeq ($(INC_OLDENV),true)
include ../../build/config/oldenv.mk
endif
# Some variables, flags etc.
E := @ echo
INCLUDE := $(realpath ../../include/e2fsprogs)
E2FSPROGS_DEFAULT_CFLAGS = \
-std=c17 \
-Wall \
-Werror \
-Wno-pointer-arith \
-Wno-sign-compare \
-Wno-type-limits \
-Wno-typedef-redefinition \
-Wno-unused-parameter \
-Wno-unused-command-line-argument \
-Wno-nullability-completeness \
-Wno-macro-redefined \
-fPIC \
-pthread \
-include $(INCLUDE)/../PartitionManager/Alternatives.h
INCLUDE_DIRS := \
$(INCLUDE)/misc \
$(INCLUDE)/blkid \
$(INCLUDE)/e2p \
$(INCLUDE)/et \
$(INCLUDE)/ext2fs \
$(INCLUDE)/ss \
$(INCLUDE)/support \
$(INCLUDE)/uuid \
$(INCLUDE)/e2fsck \
$(INCLUDE)
INC_DIRS := $(foreach dir,$(INCLUDE_DIRS),$(shell echo -I$(dir)))
CFLAGS := $(E2FSPROGS_DEFAULT_CFLAGS) $(INC_DIRS)
ARFLAGS := rcs
OUT := $(realpath ../../out/e2fsprogs)
MKE2FS := $(CURDIR)/mke2fs
LIB := $(CURDIR)/lib
LIBEXT2FS := $(LIB)/ext2fs
LIBEXT2_UUID := $(LIB)/uuid
LIBEXT2_E2P := $(LIB)/e2p
LIBEXT2_QUOTA := $(LIB)/support
LIBEXT2_MISC := $(LIB)/misc
LIBEXT2_COM_ERR := $(LIB)/et
LIBEXT2_BLKID := $(LIB)/blkid
# Source list of mke2fs
MKE2FS_SRCS := \
$(MKE2FS)/default_profile.c \
$(MKE2FS)/mk_hugefiles.c \
$(MKE2FS)/mke2fs.c \
$(MKE2FS)/util.c
# Source list of libext2fs
LIBEXT2FS_SRCS := \
$(LIBEXT2FS)/alloc.c \
$(LIBEXT2FS)/alloc_sb.c \
$(LIBEXT2FS)/alloc_stats.c \
$(LIBEXT2FS)/alloc_tables.c \
$(LIBEXT2FS)/atexit.c \
$(LIBEXT2FS)/badblocks.c \
$(LIBEXT2FS)/bb_inode.c \
$(LIBEXT2FS)/bitmaps.c \
$(LIBEXT2FS)/bitops.c \
$(LIBEXT2FS)/blkmap64_ba.c \
$(LIBEXT2FS)/blkmap64_rb.c \
$(LIBEXT2FS)/blknum.c \
$(LIBEXT2FS)/block.c \
$(LIBEXT2FS)/bmap.c \
$(LIBEXT2FS)/check_desc.c \
$(LIBEXT2FS)/crc16.c \
$(LIBEXT2FS)/crc32c.c \
$(LIBEXT2FS)/csum.c \
$(LIBEXT2FS)/closefs.c \
$(LIBEXT2FS)/dblist.c \
$(LIBEXT2FS)/dblist_dir.c \
$(LIBEXT2FS)/digest_encode.c \
$(LIBEXT2FS)/dirblock.c \
$(LIBEXT2FS)/dirhash.c \
$(LIBEXT2FS)/dir_iterate.c \
$(LIBEXT2FS)/dupfs.c \
$(LIBEXT2FS)/expanddir.c \
$(LIBEXT2FS)/ext2_err.c \
$(LIBEXT2FS)/ext_attr.c \
$(LIBEXT2FS)/extent.c \
$(LIBEXT2FS)/fallocate.c \
$(LIBEXT2FS)/fileio.c \
$(LIBEXT2FS)/finddev.c \
$(LIBEXT2FS)/flushb.c \
$(LIBEXT2FS)/freefs.c \
$(LIBEXT2FS)/gen_bitmap.c \
$(LIBEXT2FS)/gen_bitmap64.c \
$(LIBEXT2FS)/get_num_dirs.c \
$(LIBEXT2FS)/get_pathname.c \
$(LIBEXT2FS)/getsize.c \
$(LIBEXT2FS)/getsectsize.c \
$(LIBEXT2FS)/hashmap.c \
$(LIBEXT2FS)/i_block.c \
$(LIBEXT2FS)/icount.c \
$(LIBEXT2FS)/imager.c \
$(LIBEXT2FS)/ind_block.c \
$(LIBEXT2FS)/initialize.c \
$(LIBEXT2FS)/inline.c \
$(LIBEXT2FS)/inline_data.c \
$(LIBEXT2FS)/inode.c \
$(LIBEXT2FS)/io_manager.c \
$(LIBEXT2FS)/ismounted.c \
$(LIBEXT2FS)/link.c \
$(LIBEXT2FS)/llseek.c \
$(LIBEXT2FS)/lookup.c \
$(LIBEXT2FS)/mmp.c \
$(LIBEXT2FS)/mkdir.c \
$(LIBEXT2FS)/mkjournal.c \
$(LIBEXT2FS)/namei.c \
$(LIBEXT2FS)/native.c \
$(LIBEXT2FS)/newdir.c \
$(LIBEXT2FS)/nls_utf8.c \
$(LIBEXT2FS)/openfs.c \
$(LIBEXT2FS)/progress.c \
$(LIBEXT2FS)/punch.c \
$(LIBEXT2FS)/qcow2.c \
$(LIBEXT2FS)/rbtree.c \
$(LIBEXT2FS)/read_bb.c \
$(LIBEXT2FS)/read_bb_file.c \
$(LIBEXT2FS)/res_gdt.c \
$(LIBEXT2FS)/rw_bitmaps.c \
$(LIBEXT2FS)/sha256.c \
$(LIBEXT2FS)/sha512.c \
$(LIBEXT2FS)/swapfs.c \
$(LIBEXT2FS)/symlink.c \
$(LIBEXT2FS)/undo_io.c \
$(LIBEXT2FS)/unix_io.c \
$(LIBEXT2FS)/sparse_io.c \
$(LIBEXT2FS)/unlink.c \
$(LIBEXT2FS)/valid_blk.c \
$(LIBEXT2FS)/version.c \
$(LIBEXT2FS)/test_io.c
# Source list of libext2_uuid
LIBEXT2_UUID_SRCS := \
$(LIBEXT2_UUID)/clear.c \
$(LIBEXT2_UUID)/compare.c \
$(LIBEXT2_UUID)/copy.c \
$(LIBEXT2_UUID)/gen_uuid.c \
$(LIBEXT2_UUID)/isnull.c \
$(LIBEXT2_UUID)/pack.c \
$(LIBEXT2_UUID)/parse.c \
$(LIBEXT2_UUID)/unpack.c \
$(LIBEXT2_UUID)/unparse.c \
$(LIBEXT2_UUID)/uuid_time.c
# Source list of libext2_blkid
LIBEXT2_BLKID_SRCS := \
$(LIBEXT2_BLKID)/cache.c \
$(LIBEXT2_BLKID)/dev.c \
$(LIBEXT2_BLKID)/devname.c \
$(LIBEXT2_BLKID)/devno.c \
$(LIBEXT2_BLKID)/getsize.c \
$(LIBEXT2_BLKID)/llseek.c \
$(LIBEXT2_BLKID)/probe.c \
$(LIBEXT2_BLKID)/read.c \
$(LIBEXT2_BLKID)/resolve.c \
$(LIBEXT2_BLKID)/save.c \
$(LIBEXT2_BLKID)/tag.c \
$(LIBEXT2_BLKID)/version.c
# Source list of libext2_e2p
LIBEXT2_E2P_SRCS := \
$(LIBEXT2_E2P)/crypto_mode.c \
$(LIBEXT2_E2P)/encoding.c \
$(LIBEXT2_E2P)/errcode.c \
$(LIBEXT2_E2P)/feature.c \
$(LIBEXT2_E2P)/fgetflags.c \
$(LIBEXT2_E2P)/fgetproject.c \
$(LIBEXT2_E2P)/fgetversion.c \
$(LIBEXT2_E2P)/fsetflags.c \
$(LIBEXT2_E2P)/fsetproject.c \
$(LIBEXT2_E2P)/fsetversion.c \
$(LIBEXT2_E2P)/getflags.c \
$(LIBEXT2_E2P)/getversion.c \
$(LIBEXT2_E2P)/hashstr.c \
$(LIBEXT2_E2P)/iod.c \
$(LIBEXT2_E2P)/ljs.c \
$(LIBEXT2_E2P)/ls.c \
$(LIBEXT2_E2P)/mntopts.c \
$(LIBEXT2_E2P)/ostype.c \
$(LIBEXT2_E2P)/parse_num.c \
$(LIBEXT2_E2P)/pe.c \
$(LIBEXT2_E2P)/percent.c \
$(LIBEXT2_E2P)/pf.c \
$(LIBEXT2_E2P)/ps.c \
$(LIBEXT2_E2P)/setflags.c \
$(LIBEXT2_E2P)/setversion.c \
$(LIBEXT2_E2P)/uuid.c
# Source list of libext2_quota
LIBEXT2_QUOTA_SRCS := \
$(LIBEXT2_QUOTA)/devname.c \
$(LIBEXT2_QUOTA)/dict.c \
$(LIBEXT2_QUOTA)/mkquota.c \
$(LIBEXT2_QUOTA)/parse_qtype.c \
$(LIBEXT2_QUOTA)/plausible.c \
$(LIBEXT2_QUOTA)/prof_err.c \
$(LIBEXT2_QUOTA)/profile.c \
$(LIBEXT2_QUOTA)/profile_helpers.c \
$(LIBEXT2_QUOTA)/quotaio.c \
$(LIBEXT2_QUOTA)/quotaio_tree.c \
$(LIBEXT2_QUOTA)/quotaio_v2.c
# Source od libext2_misc
LIBEXT2_MISC_SRCS := $(LIBEXT2_MISC)/create_inode.c
# Source list of libext2_com_err
LIBEXT2_COM_ERR_SRCS := \
$(LIBEXT2_COM_ERR)/com_err.c \
$(LIBEXT2_COM_ERR)/com_right.c \
$(LIBEXT2_COM_ERR)/error_message.c \
$(LIBEXT2_COM_ERR)/et_name.c \
$(LIBEXT2_COM_ERR)/init_et.c
# Object lists
MKE2FS_OBJS := $(MKE2FS_SRCS:.c=.o)
LIBEXT2FS_OBJS := $(LIBEXT2FS_SRCS:.c=.o)
LIBEXT2_UUID_OBJS := $(LIBEXT2_UUID_SRCS:.c=.o)
LIBEXT2_BLKID_OBJS := $(LIBEXT2_BLKID_SRCS:.c=.o)
LIBEXT2_E2P_OBJS := $(LIBEXT2_E2P_SRCS:.c=.o)
LIBEXT2_QUOTA_OBJS := $(LIBEXT2_QUOTA_SRCS:.c=.o)
LIBEXT2_MISC_OBJS := $(LIBEXT2_MISC_SRCS:.c=.o)
LIBEXT2_COM_ERR_OBJS := $(LIBEXT2_COM_ERR_SRCS:.c=.o)
# Compiler flags (CFLAGS)
LIBEXT2FS_CFLAGS := -Wno-unused-but-set-variable
LIBEXT2_E2P_CFLAGS := -Wno-error=attributes
LIBEXT2_MISC_CFLAGS := -Wno-error=format-extra-args
LIBEXT2_BLKID_CFLAGS := \
-Wno-error=attributes \
-Wno-error=pointer-sign \
-Wno-unused-but-set-variable \
-fno-strict-aliasing
# Full object list
OBJS_ALL := \
$(MKE2FS_OBJS) \
$(LIBEXT2FS_OBJS) \
$(LIBEXT2_BLKID_OBJS) \
$(LIBEXT2_UUID_OBJS) \
$(LIBEXT2_E2P_OBJS) \
$(LIBEXT2_QUOTA_OBJS) \
$(LIBEXT2_MISC_OBJS) \
$(LIBEXT2_COM_ERR_OBJS)
# Progress list
PROGRESS_LIST := \
$(LIBEXT2_BLKID_OBJS) \
libext2_blkid_ar \
$(LIBEXT2_UUID_OBJS) \
libext2_uuid_ar \
$(LIBEXT2_E2P_OBJS) \
libext2_e2p_ar \
$(LIBEXT2FS_OBJS) \
libext2fs_ar \
$(LIBEXT2_QUOTA_OBJS) \
libext2_quota_ar \
$(LIBEXT2_MISC_OBJS) \
libext2_misc_ar \
$(LIBEXT2_COM_ERR_OBJS) \
libext2_com_err_ar \
$(MKE2FS_OBJS) \
mke2fs_dummy_ld
.PHONY: all
all: $(PROGRESS_LIST)
# Cleaner
.PHONY: clean
clean:
@ rm -rf $(OBJS_ALL)
#######################################
# 'MAKE' TARGETS FOR BUILDING OBJECTS #
#######################################
$(MKE2FS)/%.o: $(MKE2FS)/%.c
$(E) " CC e2fsprogs/`basename $(MKE2FS)`/`basename $@`"
@ $(CC) -c $(CFLAGS) $(MKE2FS_CFLAGS) "$<" -o "$@" || exit 1
$(LIBEXT2FS)/%.o: $(LIBEXT2FS)/%.c
$(E) " CC e2fsprogs/lib/`basename $(LIBEXT2FS)`/`basename $@`"
@ $(CC) -c $(CFLAGS) $(LIBEXT2FS_CFLAGS) "$<" -o "$@" || exit 1
$(LIBEXT2_BLKID)/%.o: $(LIBEXT2_BLKID)/%.c
$(E) " CC e2fsprogs/lib/`basename $(LIBEXT2_BLKID)`/`basename $@`"
@ $(CC) -c $(CFLAGS) $(LIBEXT2_BLKID_CFLAGS) "$<" -o "$@" || exit 1
$(LIBEXT2_E2P)/%.o: $(LIBEXT2_E2P)/%.c
$(E) " CC e2fsprogs/lib/`basename $(LIBEXT2_E2P)`/`basename $@`"
@ $(CC) -c $(CFLAGS) "$<" -o "$@" || exit 1
$(LIBEXT2_UUID)/%.o: $(LIBEXT2_UUID)/%.c
$(E) " CC e2fsprogs/lib/`basename $(LIBEXT2_UUID)`/`basename $@`"
@ $(CC) -c $(CFLAGS) "$<" -o "$@" || exit 1
$(LIBEXT2_QUOTA)/%.o: $(LIBEXT2_QUOTA)/%.c
$(E) " CC e2fsprogs/lib/`basename $(LIBEXT2_QUOTA)`/`basename $@`"
@ $(CC) -c $(CFLAGS) "$<" -o "$@" || exit 1
$(LIBEXT2_MISC)/%.o: $(LIBEXT2_MISC)/%.c
$(E) " CC e2fsprogs/lib/`basename $(LIBEXT2_MISC)`/`basename $@`"
@ $(CC) -c $(CFLAGS) $(LIBEXT2_MISC_CFLAGS) "$<" -o "$@" || exit 1
$(LIBEXT2_COM_ERR)/%.o: $(LIBEXT2_COM_ERR)/%.c
$(E) " CC e2fsprogs/lib/`basename $(LIBEXT2_COM_ERR)`/`basename $@`"
@ $(CC) -c $(CFLAGS) "$<" -o "$@" || exit 1
#############################################
# 'MAKE' TARGETS FOR GENERATING STATIC LIBS #
#############################################
libext2fs_ar: $(LIBEXT2FS_OBJS)
$(E) " AR out/e2fsprogs/libext2fs.a"
@ $(AR) $(ARFLAGS) $(OUT)/libext2fs.a $^ || exit 1
$(E) " ----------- libext2_quota -----------"
libext2_blkid_ar: $(LIBEXT2_BLKID_OBJS)
$(E) " AR out/e2fsprogs/libext2_blkid.a"
@ $(AR) $(ARFLAGS) $(OUT)/libext2_blkid.a $^ || exit 1
$(E) " ----------- libext2_uuid ---------"
libext2_e2p_ar: $(LIBEXT2_E2P_OBJS)
$(E) " AR out/e2fsprogs/libext2_e2p.a"
@ $(AR) $(ARFLAGS) $(OUT)/libext2_e2p.a $^ || exit 1
$(E) " ----------- libext2fs -----------"
libext2_uuid_ar: $(LIBEXT2_UUID_OBJS)
$(E) " AR out/e2fsprogs/libext2_uuid.a"
@ $(AR) $(ARFLAGS) $(OUT)/libext2_uuid.a $^ || exit 1
$(E) " ----------- libext2_e2p -----------"
libext2_quota_ar: $(LIBEXT2_QUOTA_OBJS)
$(E) " AR out/e2fsprogs/libext2_quota.a"
@ $(AR) $(ARFLAGS) $(OUT)/libext2_quota.a $^ || exit 1
$(E) " ----------- libext2_misc -----------"
libext2_misc_ar: $(LIBEXT2_MISC_OBJS)
$(E) " AR out/e2fsprogs/libext2_misc.a"
@ $(AR) $(ARFLAGS) $(OUT)/libext2_misc.a $^ || exit 1
$(E) " ----------- libext2_com_err -----------"
libext2_com_err_ar: $(LIBEXT2_COM_ERR_OBJS)
$(E) " AR out/e2fsprogs/libext2_com_err.a"
@ $(AR) $(ARFLAGS) $(OUT)/libext2_com_err.a $^ || exit 1
$(E) " ----------- mke2fs -----------"
#############################################
# DUMMY 'MAKE' TARGET FOR DISPLAYING MKE2FS #
#############################################
mke2fs_dummy_ld:
$(E) " DMY mke2fs"

View File

@@ -17,9 +17,7 @@
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#define _XOPEN_SOURCE 600
#ifndef _DARWIN_C_SOURCE
#define _DARWIN_C_SOURCE
#endif
#define _FILE_OFFSET_BITS 64
#ifndef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE

View File

@@ -76,7 +76,7 @@ extern int optind;
extern int isatty(int);
extern FILE *fpopen(const char *cmd, const char *mode);
const char * ProgramName = "mke2fs";
const char * program_name = "mke2fs";
static const char * device_name /* = NULL */;
/* Command line options */
@@ -140,7 +140,7 @@ static void usage(void)
"\t[-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior]"
"[-z undo_file]\n"
"\t[-jnqvDFSV] device [blocks-count]\n"),
ProgramName);
program_name);
exit(1);
}
@@ -1061,7 +1061,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
"Failed to parse quota type at %s", errtok);
free(errtok);
} else
com_err(ProgramName, ret,
com_err(program_name, ret,
"while parsing quota type");
r_usage++;
badopt = token;
@@ -1320,9 +1320,9 @@ static char **parse_fs_type(const char *fs_type,
ext_type = fs_type;
else if (is_hurd)
ext_type = "ext2";
else if (!strcmp(ProgramName, "mke3fs"))
else if (!strcmp(program_name, "mke3fs"))
ext_type = "ext3";
else if (!strcmp(ProgramName, "mke4fs"))
else if (!strcmp(program_name, "mke4fs"))
ext_type = "ext4";
else if (progname) {
ext_type = strrchr(progname, '/');
@@ -1643,11 +1643,11 @@ profile_error:
fs_param.s_rev_level = 0;
if (argc && *argv) {
ProgramName = get_progname(*argv);
program_name = get_progname(*argv);
/* If called as mkfs.ext3, create a journal inode */
if (!strcmp(ProgramName, "mkfs.ext3") ||
!strcmp(ProgramName, "mke3fs"))
if (!strcmp(program_name, "mkfs.ext3") ||
!strcmp(program_name, "mke3fs"))
journal_size = -1;
}
@@ -1659,7 +1659,7 @@ profile_error:
b = (blocksize > 0) ? blocksize : -blocksize;
if (b < EXT2_MIN_BLOCK_SIZE ||
b > EXT2_MAX_BLOCK_SIZE) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid block size - %s"), optarg);
exit(1);
}
@@ -1679,7 +1679,7 @@ profile_error:
cluster_size = parse_num_blocks2(optarg, -1);
if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
cluster_size > EXT2_MAX_CLUSTER_SIZE) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid cluster size - %s"),
optarg);
exit(1);
@@ -1692,7 +1692,7 @@ profile_error:
direct_io = 1;
break;
case 'R':
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("'-R' is deprecated, use '-E' instead"));
/* fallthrough */
case 'E':
@@ -1706,7 +1706,7 @@ profile_error:
else if (strcmp(optarg, "panic") == 0)
errors_behavior = EXT2_ERRORS_PANIC;
else {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("bad error behavior - %s"),
optarg);
usage();
@@ -1718,12 +1718,12 @@ profile_error:
case 'g':
fs_param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
if (*tmp) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("Illegal number for blocks per group"));
exit(1);
}
if ((fs_param.s_blocks_per_group % 8) != 0) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("blocks per group must be multiple of 8"));
exit(1);
}
@@ -1731,18 +1731,18 @@ profile_error:
case 'G':
flex_bg_size = strtoul(optarg, &tmp, 0);
if (*tmp) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("Illegal number for flex_bg size"));
exit(1);
}
if (flex_bg_size < 1 ||
(flex_bg_size & (flex_bg_size-1)) != 0) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("flex_bg size must be a power of 2"));
exit(1);
}
if (flex_bg_size > MAX_32_NUM) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("flex_bg size (%lu) must be less than"
" or equal to 2^31"), flex_bg_size);
exit(1);
@@ -1752,7 +1752,7 @@ profile_error:
inode_ratio = parse_num_blocks(optarg, -1);
if (inode_ratio < EXT2_MIN_BLOCK_SIZE ||
inode_ratio > EXT2_MAX_BLOCK_SIZE * 1024) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid inode ratio %s (min %d/max %d)"),
optarg, EXT2_MIN_BLOCK_SIZE,
EXT2_MAX_BLOCK_SIZE * 1024);
@@ -1762,7 +1762,7 @@ profile_error:
case 'I':
inode_size = strtoul(optarg, &tmp, 0);
if (*tmp) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid inode size - %s"), optarg);
exit(1);
}
@@ -1788,7 +1788,7 @@ profile_error:
bad_blocks_filename = realloc(bad_blocks_filename,
strlen(optarg) + 1);
if (!bad_blocks_filename) {
com_err(ProgramName, ENOMEM, "%s",
com_err(program_name, ENOMEM, "%s",
_("in malloc for bad_blocks_filename"));
exit(1);
}
@@ -1806,7 +1806,7 @@ profile_error:
reserved_ratio = strtod(optarg, &tmp);
if ( *tmp || reserved_ratio > 50 ||
reserved_ratio < 0) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid reserved blocks percent - %s"),
optarg);
exit(1);
@@ -1821,7 +1821,7 @@ profile_error:
case 'N':
num_inodes = strtoul(optarg, &tmp, 0);
if (*tmp) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("bad num inodes - %s"), optarg);
exit(1);
}
@@ -1834,7 +1834,7 @@ profile_error:
fs_features_size + 1 + strlen(optarg),
&fs_features);
if (retval) {
com_err(ProgramName, retval,
com_err(program_name, retval,
_("while allocating fs_feature string"));
exit(1);
}
@@ -1851,12 +1851,12 @@ profile_error:
case 'r':
r_opt = strtoul(optarg, &tmp, 0);
if (*tmp) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("bad revision level - %s"), optarg);
exit(1);
}
if (r_opt > EXT2_MAX_SUPP_REV) {
com_err(ProgramName, EXT2_ET_REV_TOO_HIGH,
com_err(program_name, EXT2_ET_REV_TOO_HIGH,
_("while trying to create revision %d"), r_opt);
exit(1);
}
@@ -1870,7 +1870,7 @@ profile_error:
break;
case 't':
if (fs_type) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("The -t option may only be used once"));
exit(1);
}
@@ -1878,7 +1878,7 @@ profile_error:
break;
case 'T':
if (usage_types) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("The -T option may only be used once"));
exit(1);
}
@@ -1933,13 +1933,13 @@ profile_error:
EXT2_FLAG_JOURNAL_DEV_OK, 0,
0, io_ptr, &jfs);
if (retval) {
com_err(ProgramName, retval,
com_err(program_name, retval,
_("while trying to open journal device %s\n"),
journal_device);
exit(1);
}
if ((blocksize < 0) && (jfs->blocksize < (unsigned) (-blocksize))) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("Journal dev blocksize (%d) smaller than "
"minimum blocksize %d\n"), jfs->blocksize,
-blocksize);
@@ -1956,7 +1956,7 @@ profile_error:
fs_blocks_count = parse_num_blocks2(argv[optind++],
fs_param.s_log_block_size);
if (!fs_blocks_count) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid blocks '%s' on device '%s'"),
argv[optind - 1], device_name);
exit(1);
@@ -2008,20 +2008,20 @@ profile_error:
}
}
if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while trying to determine filesystem size"));
exit(1);
}
if (!fs_blocks_count) {
if (retval == EXT2_ET_UNIMPLEMENTED) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("Couldn't determine device size; you "
"must specify\nthe size of the "
"filesystem\n"));
exit(1);
} else {
if (dev_size == 0) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("Device size reported to be zero. "
"Invalid partition specified, or\n\t"
"partition table wasn't reread "
@@ -2038,7 +2038,7 @@ profile_error:
EXT2_BLOCK_SIZE(&fs_param))-1));
}
} else if (!force && is_device && (fs_blocks_count > dev_size)) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("Filesystem larger than apparent device size."));
proceed_question(proceed_delay);
}
@@ -2136,13 +2136,13 @@ profile_error:
/* Get the hardware sector sizes, if available */
retval = ext2fs_get_device_sectsize(device_name, &lsector_size);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while trying to determine hardware sector size"));
exit(1);
}
retval = ext2fs_get_device_phys_sectsize(device_name, &psector_size);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while trying to determine physical sector size"));
exit(1);
}
@@ -2174,7 +2174,7 @@ profile_error:
fs_blocks_count /= (blocksize / 1024);
} else {
if (blocksize < lsector_size) { /* Impossible */
com_err(ProgramName, EINVAL, "%s",
com_err(program_name, EINVAL, "%s",
_("while setting blocksize; too small "
"for device\n"));
exit(1);
@@ -2207,7 +2207,7 @@ profile_error:
fprintf(stderr, _("%s: Size of device (0x%llx blocks) %s "
"too big to be expressed\n\t"
"in 32 bits using a blocksize of %d.\n"),
ProgramName, (unsigned long long) fs_blocks_count,
program_name, (unsigned long long) fs_blocks_count,
device_name, EXT2_BLOCK_SIZE(&fs_param));
exit(1);
}
@@ -2221,7 +2221,7 @@ profile_error:
fprintf(stderr, _("%s: Size of device (0x%llx blocks) %s "
"too big to create\n\t"
"a filesystem using a blocksize of %d.\n"),
ProgramName, (unsigned long long) fs_blocks_count,
program_name, (unsigned long long) fs_blocks_count,
device_name, EXT2_BLOCK_SIZE(&fs_param));
exit(1);
}
@@ -2277,7 +2277,7 @@ profile_error:
reserved_ratio = get_double_from_profile(
fs_types, "reserved_ratio", 5.0);
if (reserved_ratio > 50 || reserved_ratio < 0) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid reserved blocks percent - %lf"),
reserved_ratio);
exit(1);
@@ -2314,13 +2314,13 @@ profile_error:
int_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE);
if (fs_param.s_log_cluster_size &&
fs_param.s_log_cluster_size < fs_param.s_log_block_size) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("The cluster size may not be "
"smaller than the block size.\n"));
exit(1);
}
} else if (cluster_size) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("specifying a cluster size requires the "
"bigalloc feature"));
exit(1);
@@ -2384,7 +2384,7 @@ profile_error:
/* This check should happen beyond the last assignment to blocksize */
if (blocksize > sys_page_size) {
if (!force) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("%d-byte blocks too big for system (max %d)"),
blocksize, sys_page_size);
proceed_question(proceed_delay);
@@ -2442,7 +2442,7 @@ profile_error:
int encoding = e2p_str2encoding(en);
if (encoding < 0) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("Unknown filename encoding from profile: %s"),
en);
exit(1);
@@ -2453,7 +2453,7 @@ profile_error:
if (ef) {
if (e2p_str2encoding_flags(encoding, ef,
&fs_param.s_encoding_flags) < 0) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("Unknown encoding flags from profile: %s"), ef);
exit(1);
}
@@ -2493,7 +2493,7 @@ profile_error:
if (ext2fs_has_feature_project(&fs_param)) {
quotatype_bits |= QUOTA_PRJ_BIT;
if (inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("%d byte inodes are too small for "
"project quota"),
inode_size);
@@ -2515,7 +2515,7 @@ profile_error:
/* Can't support bigalloc feature without extents feature */
if (ext2fs_has_feature_bigalloc(&fs_param) &&
!ext2fs_has_feature_extents(&fs_param)) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("Can't support bigalloc feature without "
"extents feature"));
exit(1);
@@ -2543,7 +2543,7 @@ profile_error:
*/
if (ext2fs_has_feature_resize_inode(&fs_param) &&
!ext2fs_has_feature_sparse_super(&fs_param)) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("reserved online resize blocks not supported "
"on non-sparse filesystem"));
exit(1);
@@ -2552,7 +2552,7 @@ profile_error:
if (fs_param.s_blocks_per_group) {
if (fs_param.s_blocks_per_group < 256 ||
fs_param.s_blocks_per_group > 8 * (unsigned) blocksize) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("blocks per group count out of range"));
exit(1);
}
@@ -2574,7 +2574,7 @@ profile_error:
"flex_bg_size", 16);
if (flex_bg_size) {
if (!ext2fs_has_feature_flex_bg(&fs_param)) {
com_err(ProgramName, 0, "%s",
com_err(program_name, 0, "%s",
_("Flex_bg feature not enabled, so "
"flex_bg size may not be specified"));
exit(1);
@@ -2586,7 +2586,7 @@ profile_error:
if (inode_size < EXT2_GOOD_OLD_INODE_SIZE ||
inode_size > EXT2_BLOCK_SIZE(&fs_param) ||
inode_size & (inode_size - 1)) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("invalid inode size %d (min %d/max %d)"),
inode_size, EXT2_GOOD_OLD_INODE_SIZE,
blocksize);
@@ -2601,7 +2601,7 @@ profile_error:
*/
if (ext2fs_has_feature_inline_data(&fs_param) &&
fs_param.s_inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("%d byte inodes are too small for inline data; "
"specify larger size"),
fs_param.s_inode_size);
@@ -2627,7 +2627,7 @@ _("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n"));
if (ext2fs_has_feature_64bit(&fs_param))
num_inodes = MAX_32_NUM;
else {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("too many inodes (%llu), raise "
"inode ratio?"),
(unsigned long long) n);
@@ -2635,7 +2635,7 @@ _("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n"));
}
}
} else if (num_inodes > MAX_32_NUM) {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("too many inodes (%llu), specify < 2^32 inodes"),
(unsigned long long) num_inodes);
exit(1);
@@ -2650,7 +2650,7 @@ _("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n"));
(inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE)) >=
((ext2fs_blocks_count(&fs_param)) *
EXT2_BLOCK_SIZE(&fs_param))) {
com_err(ProgramName, 0, _("inode_size (%u) * inodes_count "
com_err(program_name, 0, _("inode_size (%u) * inodes_count "
"(%u) too big for a\n\t"
"filesystem with %llu blocks, "
"specify higher inode_ratio (-i)\n\t"
@@ -2795,7 +2795,7 @@ static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr)
if ((unlink(tdb_file) < 0) && (errno != ENOENT)) {
retval = errno;
com_err(ProgramName, retval,
com_err(program_name, retval,
_("while trying to delete %s"), tdb_file);
goto errout;
}
@@ -2821,7 +2821,7 @@ errout:
free(tdb_dir);
free(tdb_file);
err:
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while trying to setup undo file\n"));
return retval;
}
@@ -2921,14 +2921,14 @@ static int create_quota_inodes(ext2_filsys fs)
retval = quota_init_context(&qctx, fs, quotatype_bits);
if (retval) {
com_err(ProgramName, retval,
com_err(program_name, retval,
_("while initializing quota context"));
exit(1);
}
quota_compute_usage(qctx);
retval = quota_write_inode(qctx, quotatype_bits);
if (retval) {
com_err(ProgramName, retval,
com_err(program_name, retval,
_("while writing quota inodes"));
exit(1);
}
@@ -2953,7 +2953,7 @@ static errcode_t set_error_behavior(ext2_filsys fs)
else if (strcmp(arg, "panic") == 0)
errors = EXT2_ERRORS_PANIC;
else {
com_err(ProgramName, 0,
com_err(program_name, 0,
_("bad error behavior in profile - %s"),
arg);
free(arg);
@@ -3033,7 +3033,7 @@ int mke2fs_main (int argc, char *argv[])
char *android_sparse_params = malloc(strlen(device_name) + 48);
if (!android_sparse_params) {
com_err(ProgramName, ENOMEM, "%s",
com_err(program_name, ENOMEM, "%s",
_("in malloc for android_sparse_params"));
exit(1);
}
@@ -3202,7 +3202,7 @@ int mke2fs_main (int argc, char *argv[])
* Override the creator OS, if applicable
*/
if (creator_os && !set_os(fs->super, creator_os)) {
com_err (ProgramName, 0, _("unknown os - %s"), creator_os);
com_err (program_name, 0, _("unknown os - %s"), creator_os);
exit(1);
}
@@ -3272,7 +3272,7 @@ int mke2fs_main (int argc, char *argv[])
else
retval = ext2fs_allocate_tables(fs);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while trying to allocate filesystem tables"));
exit(1);
}
@@ -3298,7 +3298,7 @@ int mke2fs_main (int argc, char *argv[])
retval = ext2fs_convert_subcluster_bitmap(fs, &fs->block_map);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("\n\twhile converting subcluster bitmap"));
exit(1);
}
@@ -3307,7 +3307,7 @@ int mke2fs_main (int argc, char *argv[])
ext2fs_blocks_count(fs->super) - 1,
&overhead);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while calculating overhead"));
exit(1);
}
@@ -3367,7 +3367,7 @@ int mke2fs_main (int argc, char *argv[])
&ret_blk, NULL);
if (retval) {
com_err(ProgramName, retval,
com_err(program_name, retval,
_("while zeroing block %llu at end of filesystem"),
(unsigned long long) ret_blk);
}
@@ -3399,7 +3399,7 @@ int mke2fs_main (int argc, char *argv[])
EXT2_FLAG_JOURNAL_DEV_OK, 0,
fs->blocksize, default_io_manager, &jfs);
if (retval) {
com_err(ProgramName, retval,
com_err(program_name, retval,
_("while trying to open journal device %s\n"),
journal_device);
exit(1);
@@ -3411,7 +3411,7 @@ int mke2fs_main (int argc, char *argv[])
}
retval = ext2fs_add_journal_device(fs, jfs);
if(retval) {
com_err (ProgramName, retval,
com_err (program_name, retval,
_("\n\twhile trying to add journal to device %s"),
journal_device);
exit(1);
@@ -3442,7 +3442,7 @@ int mke2fs_main (int argc, char *argv[])
journal_location,
journal_flags);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("\n\twhile trying to create journal"));
exit(1);
}
@@ -3476,7 +3476,7 @@ no_journal:
retval = mk_hugefiles(fs, device_name);
if (retval)
com_err(ProgramName, retval, "while creating huge files");
com_err(program_name, retval, "while creating huge files");
/* Copy files from the specified directory */
if (src_root_dir) {
if (!quiet)
@@ -3485,7 +3485,7 @@ no_journal:
retval = populate_fs(fs, EXT2_ROOT_INO, src_root_dir,
EXT2_ROOT_INO);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while populating file system"));
exit(1);
} else if (!quiet)
@@ -3499,7 +3499,7 @@ no_journal:
max_mnt_count = fs->super->s_max_mnt_count;
retval = ext2fs_close_free(&fs);
if (retval) {
com_err(ProgramName, retval, "%s",
com_err(program_name, retval, "%s",
_("while writing out and closing file system"));
retval = 1;
} else if (!quiet) {

View File

@@ -1,675 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -1,219 +0,0 @@
# By YZBruh
# Copyright 2024 Partition Manager
#
# Licensed 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.
#####
# sub-make for building parted (built-in parted)
#####
# Include required files
include ../../build/config/env.mk
ifeq ($(INC_OLDENV),true)
include ../../build/config/oldenv.mk
endif
# Some flags etc
E := @ echo
INCLUDE_DIRS := \
$(CURDIR)/../../include \
$(CURDIR)/../../include/libgnulib \
$(CURDIR)/parted \
$(CURDIR)/libparted \
$(CURDIR)/libparted/labels \
$(CURDIR)/lib
CFLAGS := \
-Wall \
-Wextra \
-fPIC \
-Wno-pointer-sign \
-Wno-sign-compare \
-Wno-gnu-designator \
-Wno-unused-variable \
-Wno-unused-parameter \
-Wno-unused-command-line-argument \
-Wno-missing-field-initializers \
-Wno-single-bit-bitfield-constant-conversion \
$(foreach dir,$(INCLUDE_DIRS),$(shell echo -I$(dir)))
AR_FLAGS := rcs
OUT := $(realpath ../../out/parted)
LIBPARTED := libparted
PARTED := parted
PATH := $(shell echo $$PREFIX)/bin
LIBPARTED_SRCS := \
$(LIBPARTED)/architecture.c \
$(LIBPARTED)/debug.c \
$(LIBPARTED)/device.c \
$(LIBPARTED)/disk.c \
$(LIBPARTED)/exception.c \
$(LIBPARTED)/filesys.c \
$(LIBPARTED)/libparted.c \
$(LIBPARTED)/timer.c \
$(LIBPARTED)/unit.c \
$(LIBPARTED)/arch/linux.c \
$(LIBPARTED)/cs/constraint.c \
$(LIBPARTED)/cs/geom.c \
$(LIBPARTED)/cs/natmath.c \
$(LIBPARTED)/fs/amiga/a-interface.c \
$(LIBPARTED)/fs/amiga/affs.c \
$(LIBPARTED)/fs/amiga/amiga.c \
$(LIBPARTED)/fs/amiga/apfs.c \
$(LIBPARTED)/fs/amiga/asfs.c \
$(LIBPARTED)/fs/btrfs/btrfs.c \
$(LIBPARTED)/fs/ext2/interface.c \
$(LIBPARTED)/fs/f2fs/f2fs.c \
$(LIBPARTED)/fs/fat/bootsector.c \
$(LIBPARTED)/fs/fat/fat.c \
$(LIBPARTED)/fs/hfs/hfs.c \
$(LIBPARTED)/fs/hfs/probe.c \
$(LIBPARTED)/fs/jfs/jfs.c \
$(LIBPARTED)/fs/linux_swap/linux_swap.c \
$(LIBPARTED)/fs/nilfs2/nilfs2.c \
$(LIBPARTED)/fs/ntfs/ntfs.c \
$(LIBPARTED)/fs/r/filesys.c \
$(LIBPARTED)/fs/r/fat/bootsector.c \
$(LIBPARTED)/fs/r/fat/calc.c \
$(LIBPARTED)/fs/r/fat/clstdup.c \
$(LIBPARTED)/fs/r/fat/context.c \
$(LIBPARTED)/fs/r/fat/count.c \
$(LIBPARTED)/fs/r/fat/fat.c \
$(LIBPARTED)/fs/r/fat/fatio.c \
$(LIBPARTED)/fs/r/fat/resize.c \
$(LIBPARTED)/fs/r/fat/table.c \
$(LIBPARTED)/fs/r/fat/traverse.c \
$(LIBPARTED)/fs/r/hfs/advfs.c \
$(LIBPARTED)/fs/r/hfs/advfs_plus.c \
$(LIBPARTED)/fs/r/hfs/cache.c \
$(LIBPARTED)/fs/r/hfs/file.c \
$(LIBPARTED)/fs/r/hfs/file_plus.c \
$(LIBPARTED)/fs/r/hfs/hfs.c \
$(LIBPARTED)/fs/r/hfs/journal.c \
$(LIBPARTED)/fs/r/hfs/probe.c \
$(LIBPARTED)/fs/r/hfs/reloc.c \
$(LIBPARTED)/fs/r/hfs/reloc_plus.c \
$(LIBPARTED)/fs/reiserfs/reiserfs.c \
$(LIBPARTED)/fs/udf/udf.c \
$(LIBPARTED)/fs/ufs/ufs.c \
$(LIBPARTED)/fs/xfs/xfs.c \
$(LIBPARTED)/labels/aix.c \
$(LIBPARTED)/labels/atari.c \
$(LIBPARTED)/labels/bsd.c \
$(LIBPARTED)/labels/dos.c \
$(LIBPARTED)/labels/dvh.c \
$(LIBPARTED)/labels/efi_crc32.c \
$(LIBPARTED)/labels/fdasd.c \
$(LIBPARTED)/labels/gpt.c \
$(LIBPARTED)/labels/loop.c \
$(LIBPARTED)/labels/mac.c \
$(LIBPARTED)/labels/pt-tools.c \
$(LIBPARTED)/labels/rdb.c \
$(LIBPARTED)/labels/sun.c \
$(LIBPARTED)/labels/vtoc.c
PARTED_SRCS := \
$(PARTED)/command.c \
$(PARTED)/jsonwrt.c \
$(PARTED)/parted.c \
$(PARTED)/strlist.c \
$(PARTED)/table.c \
$(PARTED)/ui.c \
$(PARTED)/version.c
LIBPARTED_OBJS := $(LIBPARTED_SRCS:.c=.o)
PARTED_OBJS := $(PARTED_SRCS:.c=.o)
OBJS_ALL := \
$(LIBPARTED_OBJS) \
$(PARTED_OBJS)
PROGRESS_LIST := \
make_outdir \
build_libgnulib \
build_libcharset \
build_libiconv_and_libicrt \
print_libparted \
$(LIBPARTED_OBJS) \
libparted_ar \
print_parted \
$(PARTED_OBJS) \
dummy_parted
.PHONY: all
all: $(PROGRESS_LIST)
.PHONY: clean
clean:
@ rm -rf $(OBJS_ALL) $(OUT) *.a
@ $(MAKE) -C $(CURDIR)/libgnulib -s clean
@ $(MAKE) -C $(CURDIR)/libiconv -s clean
@ $(MAKE) -C $(CURDIR)/libcharset -s clean
.PHONY: install
install:
@ abort() { \
echo "$1"; \
exit 1; \
}; \
[ -f $(PATH)/parted-test ] && \
abort "Already installed."; \
cp $(OUT)/parted $(PATH)/parted-test || \
abort "Copying failed!"; \
chmod 777 $(PATH)/parted-test || \
abort "Cannot set permissions!"
.PHONY: uninstall
uninstall:
@ if [ ! -f $(PATH)/parted-test ]; then echo "Already uninstalled"; exit 1; fi
@ rm -f $(PATH)/parted-test &>/dev/null
.PHONY:
reinstall:
@ $(MAKE) -s uninstall
@ $(MAKE) -s install
$(LIBPARTED)/%.o: $(LIBPARTED)/%.c
$(E) " CC $@"
@ $(CC) -c $(CFLAGS) -o $@ $^ || exit 1
$(PARTED)/%.o: $(PARTED)/%.c
$(E) " CC $@"
@ $(CC) -c $(CFLAGS) -o $@ $^ || exit 1
libparted_ar: $(LIBPARTED_OBJS)
$(E) " AR out/parted/libparted.a"
@ $(AR) $(AR_FLAGS) $(OUT)/libparted.a $(LIBPARTED_OBJS)
build_libgnulib:
@ $(MAKE) -C $(CURDIR)/libgnulib -s
build_libcharset:
$(E) " ----------- libcharset ----------- "
@ $(MAKE) -C $(CURDIR)/libcharset -s
build_libiconv_and_libicrt:
$(E) " ----------- libicrt ----------- "
@ $(MAKE) -C $(CURDIR)/libiconv -s
make_outdir:
@ if [ ! -d $(OUT) ]; then mkdir -p $(OUT); fi
print_libparted:
$(E) " ----------- libparted ----------- "
print_parted:
$(E) " ----------- parted ----------- "
dummy_parted:
$(E) " DMY parted"

View File

@@ -1,73 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2004, 2006-2024 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
means there is a real alloca function. */
#ifndef _GL_ALLOCA_H
#define _GL_ALLOCA_H
/* alloca (N) returns a pointer to N bytes of memory
allocated on the stack, which will last until the function returns.
Use of alloca should be avoided:
- inside arguments of function calls - undefined behaviour,
- in inline functions - the allocation may actually last until the
calling function returns,
- for huge N (say, N >= 65536) - you never know how large (or small)
the stack is, and when the stack cannot fulfill the memory allocation
request, the program just crashes.
*/
#ifndef alloca
/* Some version of mingw have an <alloca.h> that causes trouble when
included after 'alloca' gets defined as a macro. As a workaround,
include this <alloca.h> first and define 'alloca' as a macro afterwards
if needed. */
# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && 1
# include_next <alloca.h>
# endif
#endif
#ifndef alloca
# if defined __GNUC__ || (__clang_major__ >= 4)
# define alloca __builtin_alloca
# elif defined _AIX
# define alloca __alloca
# elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
# elif defined __DECC && defined __VMS
# define alloca __ALLOCA
# elif defined __TANDEM && defined _TNS_E_TARGET
# ifdef __cplusplus
extern "C"
# endif
void *_alloca (unsigned short);
# pragma intrinsic (_alloca)
# define alloca _alloca
# elif defined __MVS__
# include <stdlib.h>
# else
# include <stddef.h>
# ifdef __cplusplus
extern "C"
# endif
void *alloca (size_t);
# endif
#endif
#endif /* _GL_ALLOCA_H */

View File

@@ -1,323 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Substitute for and wrapper around <assert.h>
Copyright (C) 2011-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Do not guard the include, since <assert.h> is supposed to define
the assert macro each time it is included. */
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
#include_next <assert.h>
/* The definition of static_assert is copied here. */
/* Compile-time assert-like macros.
Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
#ifndef _GL_STATIC_ASSERT_H
#define _GL_STATIC_ASSERT_H
/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC)
works as per C11. This is supported by GCC 4.6.0+ and by clang 4+.
Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
per C23. This is supported by GCC 9.1+.
Support compilers claiming conformance to the relevant standard,
and also support GCC when not pedantic. If we were willing to slow
'configure' down we could also use it with other compilers, but
since this affects only the quality of diagnostics, why bother? */
#ifndef __cplusplus
# if (201112 <= __STDC_VERSION__ \
|| (!defined __STRICT_ANSI__ \
&& ((4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__) \
|| 5 <= __clang_major__)))
# define _GL_HAVE__STATIC_ASSERT 1
# endif
# if (202311 <= __STDC_VERSION__ \
|| (!defined __STRICT_ANSI__ && 9 <= __GNUC__ && !defined __clang__))
# define _GL_HAVE__STATIC_ASSERT1 1
# endif
#endif
/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
system headers, defines a conflicting _Static_assert that is no
better than ours; override it. */
#ifndef _GL_HAVE__STATIC_ASSERT
# include <stddef.h>
# undef _Static_assert
#endif
/* Each of these macros verifies that its argument R is nonzero. To
be portable, R should be an integer constant expression. Unlike
assert (R), there is no run-time overhead.
If _Static_assert works, verify (R) uses it directly. Similarly,
_GL_STATIC_ASSERT_TRUE works by packaging a _Static_assert inside a struct
that is an operand of sizeof.
The code below uses several ideas for C++ compilers, and for C
compilers that do not support _Static_assert:
* The first step is ((R) ? 1 : -1). Given an expression R, of
integral or boolean or floating-point type, this yields an
expression of integral type, whose value is later verified to be
constant and nonnegative.
* Next this expression W is wrapped in a type
struct _gl_static_assert_type {
unsigned int _gl_static_assert_error_if_negative: W;
}.
If W is negative, this yields a compile-time error. No compiler can
deal with a bit-field of negative size.
One might think that an array size check would have the same
effect, that is, that the type struct { unsigned int dummy[W]; }
would work as well. However, inside a function, some compilers
(such as C++ compilers and GNU C) allow local parameters and
variables inside array size expressions. With these compilers,
an array size check would not properly diagnose this misuse of
the verify macro:
void function (int n) { verify (n < 0); }
* For the verify macro, the struct _gl_static_assert_type will need to
somehow be embedded into a declaration. To be portable, this
declaration must declare an object, a constant, a function, or a
typedef name. If the declared entity uses the type directly,
such as in
struct dummy {...};
typedef struct {...} dummy;
extern struct {...} *dummy;
extern void dummy (struct {...} *);
extern struct {...} *dummy (void);
two uses of the verify macro would yield colliding declarations
if the entity names are not disambiguated. A workaround is to
attach the current line number to the entity name:
#define _GL_CONCAT0(x, y) x##y
#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
extern struct {...} * _GL_CONCAT (dummy, __LINE__);
But this has the problem that two invocations of verify from
within the same macro would collide, since the __LINE__ value
would be the same for both invocations. (The GCC __COUNTER__
macro solves this problem, but is not portable.)
A solution is to use the sizeof operator. It yields a number,
getting rid of the identity of the type. Declarations like
extern int dummy [sizeof (struct {...})];
extern void dummy (int [sizeof (struct {...})]);
extern int (*dummy (void)) [sizeof (struct {...})];
can be repeated.
* Should the implementation use a named struct or an unnamed struct?
Which of the following alternatives can be used?
extern int dummy [sizeof (struct {...})];
extern int dummy [sizeof (struct _gl_static_assert_type {...})];
extern void dummy (int [sizeof (struct {...})]);
extern void dummy (int [sizeof (struct _gl_static_assert_type {...})]);
extern int (*dummy (void)) [sizeof (struct {...})];
extern int (*dummy (void)) [sizeof (struct _gl_static_assert_type {...})];
In the second and sixth case, the struct type is exported to the
outer scope; two such declarations therefore collide. GCC warns
about the first, third, and fourth cases. So the only remaining
possibility is the fifth case:
extern int (*dummy (void)) [sizeof (struct {...})];
* GCC warns about duplicate declarations of the dummy function if
-Wredundant-decls is used. GCC 4.3 and later have a builtin
__COUNTER__ macro that can let us generate unique identifiers for
each dummy function, to suppress this warning.
* This implementation exploits the fact that older versions of GCC,
which do not support _Static_assert, also do not warn about the
last declaration mentioned above.
* GCC warns if -Wnested-externs is enabled and 'verify' is used
within a function body; but inside a function, you can always
arrange to use verify_expr instead.
* In C++, any struct definition inside sizeof is invalid.
Use a template type to work around the problem. */
/* Concatenate two preprocessor tokens. */
#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
#define _GL_CONCAT0(x, y) x##y
/* _GL_COUNTER is an integer, preferably one that changes each time we
use it. Use __COUNTER__ if it works, falling back on __LINE__
otherwise. __LINE__ isn't perfect, but it's better than a
constant. */
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
# define _GL_COUNTER __COUNTER__
#else
# define _GL_COUNTER __LINE__
#endif
/* Generate a symbol with the given prefix, making it unique if
possible. */
#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
/* Verify requirement R at compile-time, as an integer constant expression
that returns 1. If R is false, fail at compile-time, preferably
with a diagnostic that includes the string-literal DIAGNOSTIC. */
#define _GL_STATIC_ASSERT_TRUE(R, DIAGNOSTIC) \
(!!sizeof (_GL_STATIC_ASSERT_TYPE (R, DIAGNOSTIC)))
#ifdef __cplusplus
# if !GNULIB_defined_struct__gl_static_assert_type
template <int w>
struct _gl_static_assert_type {
unsigned int _gl_static_assert_error_if_negative: w;
};
# define GNULIB_defined_struct__gl_static_assert_type 1
# endif
# define _GL_STATIC_ASSERT_TYPE(R, DIAGNOSTIC) \
_gl_static_assert_type<(R) ? 1 : -1>
#elif defined _GL_HAVE__STATIC_ASSERT
# define _GL_STATIC_ASSERT_TYPE(R, DIAGNOSTIC) \
struct { \
_Static_assert (R, DIAGNOSTIC); \
int _gl_dummy; \
}
#else
# define _GL_STATIC_ASSERT_TYPE(R, DIAGNOSTIC) \
struct { unsigned int _gl_static_assert_error_if_negative: (R) ? 1 : -1; }
#endif
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. If R is false, fail at compile-time.
This macro requires three or more arguments but uses at most the first
two, so that the _Static_assert macro optionally defined below supports
both the C11 two-argument syntax and the C23 one-argument syntax.
Unfortunately, unlike C11, this implementation must appear as an
ordinary declaration, and cannot appear inside struct { ... }. */
#if 202311 <= __STDC_VERSION__ || 200410 <= __cpp_static_assert
# define _GL_STATIC_ASSERT(R, DIAGNOSTIC, ...) static_assert (R, DIAGNOSTIC)
#elif defined _GL_HAVE__STATIC_ASSERT
# define _GL_STATIC_ASSERT(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
#else
# define _GL_STATIC_ASSERT(R, DIAGNOSTIC, ...) \
extern int (*_GL_GENSYM (_gl_static_assert_function) (void)) \
[_GL_STATIC_ASSERT_TRUE (R, DIAGNOSTIC)]
# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__
# pragma GCC diagnostic ignored "-Wnested-externs"
# endif
#endif
/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
#ifdef _GL_STATIC_ASSERT_H
/* Define _Static_assert if needed. */
/* With clang ≥ 3.8.0 in C++ mode, _Static_assert already works and accepts
1 or 2 arguments. We better don't override it, because clang's standard
C++ library uses static_assert inside classes in several places, and our
replacement via _GL_STATIC_ASSERT does not work in these contexts. */
# if (defined __cplusplus && defined __clang__ \
&& (4 <= __clang_major__ + (8 <= __clang_minor__)))
# if 5 <= __clang_major__
/* Avoid "warning: 'static_assert' with no message is a C++17 extension". */
# pragma clang diagnostic ignored "-Wc++17-extensions"
# else
/* Avoid "warning: static_assert with no message is a C++1z extension". */
# pragma clang diagnostic ignored "-Wc++1z-extensions"
# endif
# elif !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert
# if !defined _MSC_VER || defined __clang__
# define _Static_assert(...) \
_GL_STATIC_ASSERT (__VA_ARGS__, "static assertion failed", -)
# else
# if defined __cplusplus && _MSC_VER >= 1910
/* In MSVC 14.1 or newer, static_assert accepts one or two arguments,
but _Static_assert is not defined. */
# define _Static_assert static_assert
# else
/* Work around MSVC preprocessor incompatibility with ISO C; see
<https://stackoverflow.com/questions/5134523/>. */
# define _Static_assert(R, ...) \
_GL_STATIC_ASSERT ((R), "static assertion failed", -)
# endif
# endif
# endif
/* Define static_assert if needed. */
# if (!defined static_assert \
&& __STDC_VERSION__ < 202311 \
&& (!defined __cplusplus \
|| (__cpp_static_assert < 201411 \
&& __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910)))
# if (defined __cplusplus && defined __GNUG__ && __GNUG__ < 6 \
&& __cplusplus == 201103L && !defined __clang__)
/* g++ >= 4.7, < 6 with option -std=c++11 or -std=gnu++11 supports the
two-arguments static_assert but not the one-argument static_assert, and
it does not support _Static_assert.
We have to play preprocessor tricks to distinguish the two cases. */
# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
# define _GL_SA2 static_assert
# define _GL_SA3 static_assert
# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
# define static_assert(...) _GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1) (__VA_ARGS__)
# elif defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
the one-argument static_assert, and it does not support _Static_assert.
We have to play preprocessor tricks to distinguish the two cases.
Since the MSVC preprocessor is not ISO C compliant (see above),
the solution is specific to MSVC. */
# define _GL_EXPAND(x) x
# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
# define _GL_SA2 static_assert
# define _GL_SA3 static_assert
# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__)
/* Avoid "fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords." */
# define _ALLOW_KEYWORD_MACROS 1
# else
# define static_assert _Static_assert /* C11 requires this #define. */
# endif
# endif
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
#if HAVE_WINSOCK2_H
# include <winsock2.h> /* avoid mingw pollution on DATADIR */
#endif
#define PREFIX "/usr/local"
#define EXEC_PREFIX "/usr/local"
#define BINDIR "/usr/local/bin"
#define SBINDIR "/usr/local/sbin"
#define LIBEXECDIR "/usr/local/libexec"
#define DATAROOTDIR "/usr/local/share"
#define DATADIR "/usr/local/share"
#define SYSCONFDIR "/usr/local/etc"
#define SHAREDSTATEDIR "/usr/local/com"
#define LOCALSTATEDIR "/usr/local/var"
#define RUNSTATEDIR "/usr/local/var/run"
#define INCLUDEDIR "/usr/local/include"
#define OLDINCLUDEDIR "/usr/include"
#define DOCDIR "/usr/local/share/doc/parted"
#define INFODIR "/usr/local/share/info"
#define HTMLDIR "/usr/local/share/doc/parted"
#define DVIDIR "/usr/local/share/doc/parted"
#define PDFDIR "/usr/local/share/doc/parted"
#define PSDIR "/usr/local/share/doc/parted"
#define LIBDIR "/usr/local/lib"
#define LISPDIR "/usr/local/share/emacs/site-lisp"
#define LOCALEDIR "/usr/local/share/locale"
#define MANDIR "/usr/local/share/man"
#define PKGDATADIR "/usr/local/share/parted"
#define PKGINCLUDEDIR "/usr/local/include/parted"
#define PKGLIBDIR "/usr/local/lib/parted"
#define PKGLIBEXECDIR "/usr/local/libexec/parted"

View File

@@ -1,619 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Declarations for error-reporting functions.
Copyright (C) 1995-1997, 2003, 2006, 2008-2024 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_ERROR_H
/* No @PRAGMA_SYSTEM_HEADER@ here, because it would prevent
-Wimplicit-fallthrough warnings for missing FALLTHROUGH after error(...)
or error_at_line(...) invocations. */
/* The include_next requires a split double-inclusion guard. */
#if 1 && !defined __MINGW32__
# include_next <error.h>
#endif
#ifndef _GL_ERROR_H
#define _GL_ERROR_H
/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_COLD,
_GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_MAYBE_UNUSED. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
/* Get va_list. */
#include <stdarg.h>
/* Get 'unreachable'. */
#include <stddef.h>
/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */
#include <stdio.h>
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* C++ compatible function declaration macros.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
/* Begin/end the GNULIB_NAMESPACE namespace. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif
/* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some
platforms, but is declared and works fine on the platforms on which
it exists:
#if @GNULIB_FOO@
# if !@HAVE_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on all platforms,
but is broken/insufficient and needs to be replaced on some platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on some platforms
but is broken/insufficient and needs to be replaced on some of them and
is additionally either missing or undeclared on some other platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
# if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
*/
/* _GL_EXTERN_C declaration;
performs the declaration with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C extern "C"
#else
# define _GL_EXTERN_C extern
#endif
/* _GL_EXTERN_C_FUNC declaration;
performs the declaration of a function with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C_FUNC extern "C"
#else
/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
are not allowed between 'extern' and the return type (see gnulib-common.m4).
*/
# define _GL_EXTERN_C_FUNC
#endif
/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
declares a replacement function, named rpl_func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
_GL_ARG_NONNULL ((1)));
Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
because
[[...]] extern "C" <declaration>;
is invalid syntax in C++.)
*/
#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
declares the system function, named func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
*/
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
Wrapping rpl_func in an object with an inline conversion operator
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::rpl_func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
is to be used when func is a Microsoft deprecated alias, on native Windows.
It declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to _func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
*/
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
except that the C function rpl_func may have a slightly different
declaration. A cast is used to silence the "invalid conversion" error
that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::rpl_func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
Wrapping func in an object with an inline conversion operator
avoids a reference to func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function is picked among a set of overloaded functions,
namely the one with rettype2 and parameters2. Two consecutive casts
are used to silence the "cannot find a match" and "invalid conversion"
errors that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
/* The outer cast must be a reinterpret_cast.
The inner cast: When the function is defined as a set of overloaded
functions, it works as a static_cast<>, choosing the designated variant.
When the function is defined as a single variant, it works as a
reinterpret_cast<>. The parenthesized cast syntax works both ways. */
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN (func);
causes a warning to be emitted when ::func is used but not when
GNULIB_NAMESPACE::func is used. func must be defined without overloaded
variants. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN(func) \
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN_2(func,namespace) \
extern __typeof__ (func) func
# else
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN(func) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
causes a warning to be emitted when the given overloaded variant of ::func
is used but not when GNULIB_NAMESPACE::func is used. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# else
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
#endif /* _GL_CXXDEFS_H */
#if GNULIB_VFPRINTF_POSIX
# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
#else
# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM
#endif
/* Helper macro for supporting the compiler's control flow analysis better.
It evaluates its arguments only once.
Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */
#if defined __GNUC__ || defined __clang__
/* Use 'unreachable' to tell the compiler when the function call does not
return. */
# define __gl_error_call1(function, status, ...) \
((function) (status, __VA_ARGS__), \
(status) != 0 ? unreachable () : (void) 0)
/* If STATUS is a not a constant, the function call may or may not return;
therefore -Wimplicit-fallthrough will produce a warning. Use a compound
statement in order to evaluate STATUS only once.
If STATUS is a constant, we don't use a compound statement, because that
would trigger a -Wimplicit-fallthrough warning even when STATUS is != 0,
when not optimizing. This causes STATUS to be evaluated twice, but
that's OK since it does not have side effects. */
# define __gl_error_call(function, status, ...) \
(__builtin_constant_p (status) \
? __gl_error_call1 (function, status, __VA_ARGS__) \
: __extension__ \
({ \
int const __errstatus = status; \
__gl_error_call1 (function, __errstatus, __VA_ARGS__); \
}))
#else
# define __gl_error_call(function, status, ...) \
(function) (status, __VA_ARGS__)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Print a message with 'fprintf (stderr, FORMAT, ...)';
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
#if 1
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef error
# define error rpl_error
# endif
_GL_FUNCDECL_RPL (error, void,
(int __status, int __errnum, const char *__format, ...),
_GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
_GL_CXXALIAS_RPL (error, void,
(int __status, int __errnum, const char *__format, ...));
# ifndef _GL_NO_INLINE_ERROR
# undef error
# define error(status, ...) \
__gl_error_call (rpl_error, status, __VA_ARGS__)
# endif
#else
# if ! 1
_GL_FUNCDECL_SYS (error, void,
(int __status, int __errnum, const char *__format, ...),
_GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
# endif
_GL_CXXALIAS_SYS (error, void,
(int __status, int __errnum, const char *__format, ...));
# ifndef _GL_NO_INLINE_ERROR
# ifdef error
/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */
# if _GL_GNUC_PREREQ (4, 7)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
_GL_ATTRIBUTE_MAYBE_UNUSED
static void
_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))
_gl_inline_error (int __status, int __errnum, const char *__format, ...)
{
return error (__status, __errnum, __format, __builtin_va_arg_pack ());
}
# pragma GCC diagnostic pop
# undef error
# define error(status, ...) \
__gl_error_call (_gl_inline_error, status, __VA_ARGS__)
# endif
# else
# define error(status, ...) \
__gl_error_call (error, status, __VA_ARGS__)
# endif
# endif
#endif
#if __GLIBC__ >= 2
_GL_CXXALIASWARN (error);
#endif
/* Likewise. If FILENAME is non-NULL, include FILENAME:LINENO: in the
message. */
#if 1
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef error_at_line
# define error_at_line rpl_error_at_line
# endif
_GL_FUNCDECL_RPL (error_at_line, void,
(int __status, int __errnum, const char *__filename,
unsigned int __lineno, const char *__format, ...),
_GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
_GL_CXXALIAS_RPL (error_at_line, void,
(int __status, int __errnum, const char *__filename,
unsigned int __lineno, const char *__format, ...));
# ifndef _GL_NO_INLINE_ERROR
# undef error_at_line
# define error_at_line(status, ...) \
__gl_error_call (rpl_error_at_line, status, __VA_ARGS__)
# endif
#else
# if ! 1
_GL_FUNCDECL_SYS (error_at_line, void,
(int __status, int __errnum, const char *__filename,
unsigned int __lineno, const char *__format, ...),
_GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
# endif
_GL_CXXALIAS_SYS (error_at_line, void,
(int __status, int __errnum, const char *__filename,
unsigned int __lineno, const char *__format, ...));
# ifndef _GL_NO_INLINE_ERROR
# ifdef error_at_line
/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */
# if _GL_GNUC_PREREQ (4, 7)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
_GL_ATTRIBUTE_MAYBE_UNUSED
static void
_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))
_gl_inline_error_at_line (int __status, int __errnum, const char *__filename,
unsigned int __lineno, const char *__format, ...)
{
return error_at_line (__status, __errnum, __filename, __lineno, __format,
__builtin_va_arg_pack ());
}
# pragma GCC diagnostic pop
# undef error_at_line
# define error_at_line(status, ...) \
__gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__)
# endif
# else
# define error_at_line(status, ...) \
__gl_error_call (error_at_line, status, __VA_ARGS__)
# endif
# endif
#endif
_GL_CXXALIASWARN (error_at_line);
/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)';
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
If STATUS is nonzero, terminate the program with 'exit (STATUS)'.
Use the globals error_print_progname and error_message_count similarly
to error(). */
extern void verror (int __status, int __errnum, const char *__format,
va_list __args)
_GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
#ifndef _GL_NO_INLINE_ERROR
# ifndef verror
# define verror(status, ...) \
__gl_error_call (verror, status, __VA_ARGS__)
# define GNULIB_defined_verror 1
# endif
#endif
/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)';
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
If STATUS is nonzero, terminate the program with 'exit (STATUS)'.
If FNAME is not NULL, prepend the message with "FNAME:LINENO:".
Use the globals error_print_progname, error_message_count, and
error_one_per_line similarly to error_at_line(). */
extern void verror_at_line (int __status, int __errnum, const char *__fname,
unsigned int __lineno, const char *__format,
va_list __args)
_GL_ATTRIBUTE_COLD
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0));
#ifdef _GL_NO_INLINE_ERROR
# ifndef verror_at_line
# define verror_at_line(status, ...) \
__gl_error_call (verror_at_line, status, __VA_ARGS__)
# define GNULIB_defined_verror_at_line 1
# endif
#endif
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
extern void (*error_print_progname) (void);
/* This variable is incremented each time 'error' is called. */
extern unsigned int error_message_count;
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
extern int error_one_per_line;
#ifdef __cplusplus
}
#endif
#endif /* _GL_ERROR_H */
#endif /* _GL_ERROR_H */

View File

@@ -1,988 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Like <fcntl.h>, but with non-working flags defined to 0.
Copyright (C) 2006-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Paul Eggert */
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
#if defined __need_system_fcntl_h
/* Special invocation convention. */
/* Needed before <sys/stat.h>.
May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
extern "C" { ... } block, which leads to errors in C++ mode with the
overridden <sys/stat.h> from gnulib. These errors are known to be gone
with g++ version >= 4.3. */
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include <sys/stat.h>
#endif
#include_next <fcntl.h>
/* Native Windows platforms declare open(), creat() in <io.h>. */
#if (0 || 1 || defined GNULIB_POSIXCHECK) \
&& (defined _WIN32 && ! defined __CYGWIN__)
# include <io.h>
#endif
#else
/* Normal invocation convention. */
#ifndef _GL_FCNTL_H
/* Needed before <sys/stat.h>.
May also define off_t to a 64-bit type on native Windows.
Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
#include <sys/types.h>
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
extern "C" { ... } block, which leads to errors in C++ mode with the
overridden <sys/stat.h> from gnulib. These errors are known to be gone
with g++ version >= 4.3. */
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include <sys/stat.h>
#endif
/* The include_next requires a split double-inclusion guard. */
#include_next <fcntl.h>
/* Native Windows platforms declare open(), creat() in <io.h>. */
#if (0 || 1 || defined GNULIB_POSIXCHECK) \
&& (defined _WIN32 && ! defined __CYGWIN__)
# include <io.h>
#endif
#ifndef _GL_FCNTL_H
#define _GL_FCNTL_H
/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
# include <unistd.h>
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* C++ compatible function declaration macros.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
/* Begin/end the GNULIB_NAMESPACE namespace. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif
/* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some
platforms, but is declared and works fine on the platforms on which
it exists:
#if @GNULIB_FOO@
# if !@HAVE_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on all platforms,
but is broken/insufficient and needs to be replaced on some platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on some platforms
but is broken/insufficient and needs to be replaced on some of them and
is additionally either missing or undeclared on some other platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
# if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
*/
/* _GL_EXTERN_C declaration;
performs the declaration with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C extern "C"
#else
# define _GL_EXTERN_C extern
#endif
/* _GL_EXTERN_C_FUNC declaration;
performs the declaration of a function with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C_FUNC extern "C"
#else
/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
are not allowed between 'extern' and the return type (see gnulib-common.m4).
*/
# define _GL_EXTERN_C_FUNC
#endif
/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
declares a replacement function, named rpl_func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
_GL_ARG_NONNULL ((1)));
Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
because
[[...]] extern "C" <declaration>;
is invalid syntax in C++.)
*/
#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
declares the system function, named func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
*/
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
Wrapping rpl_func in an object with an inline conversion operator
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::rpl_func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
is to be used when func is a Microsoft deprecated alias, on native Windows.
It declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to _func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
*/
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
except that the C function rpl_func may have a slightly different
declaration. A cast is used to silence the "invalid conversion" error
that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::rpl_func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
Wrapping func in an object with an inline conversion operator
avoids a reference to func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function is picked among a set of overloaded functions,
namely the one with rettype2 and parameters2. Two consecutive casts
are used to silence the "cannot find a match" and "invalid conversion"
errors that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
/* The outer cast must be a reinterpret_cast.
The inner cast: When the function is defined as a set of overloaded
functions, it works as a static_cast<>, choosing the designated variant.
When the function is defined as a single variant, it works as a
reinterpret_cast<>. The parenthesized cast syntax works both ways. */
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN (func);
causes a warning to be emitted when ::func is used but not when
GNULIB_NAMESPACE::func is used. func must be defined without overloaded
variants. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN(func) \
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN_2(func,namespace) \
extern __typeof__ (func) func
# else
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN(func) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
causes a warning to be emitted when the given overloaded variant of ::func
is used but not when GNULIB_NAMESPACE::func is used. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# else
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
#endif /* _GL_CXXDEFS_H */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers.
n = 1 stands for the first argument, n = 2 for the second argument etc. */
#ifndef _GL_ARG_NONNULL
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
# else
# define _GL_ARG_NONNULL(params)
# endif
#endif
/* The definition of _GL_WARN_ON_USE is copied here. */
/* A C macro for emitting warnings if a function is used.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
for FUNCTION which will then trigger a compiler warning containing
the text of "literal string" anywhere that function is called, if
supported by the compiler. If the compiler does not support this
feature, the macro expands to an unused extern declaration.
_GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
attribute used in _GL_WARN_ON_USE. If the compiler does not support
this feature, it expands to empty.
These macros are useful for marking a function as a potential
portability trap, with the intent that "literal string" include
instructions on the replacement function that should be used
instead.
_GL_WARN_ON_USE is for functions with 'extern' linkage.
_GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
linkage.
_GL_WARN_ON_USE should not be used more than once for a given function
in a given compilation unit (because this may generate a warning even
if the function is never called).
However, one of the reasons that a function is a portability trap is
if it has the wrong signature. Declaring FUNCTION with a different
signature in C is a compilation error, so this macro must use the
same type as any existing declaration so that programs that avoid
the problematic FUNCTION do not fail to compile merely because they
included a header that poisoned the function. But this implies that
_GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
have a declaration. Use of this macro implies that there must not
be any other macro hiding the declaration of FUNCTION; but
undefining FUNCTION first is part of the poisoning process anyway
(although for symbols that are provided only via a macro, the result
is a compilation error rather than a warning containing
"literal string"). Also note that in C++, it is only safe to use if
FUNCTION has no overloads.
For an example, it is possible to poison 'getline' by:
- adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
[getline]) in configure.ac, which potentially defines
HAVE_RAW_DECL_GETLINE
- adding this code to a header that wraps the system <stdio.h>:
#undef getline
#if HAVE_RAW_DECL_GETLINE
_GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
"not universally present; use the gnulib module getline");
#endif
It is not possible to directly poison global variables. But it is
possible to write a wrapper accessor function, and poison that
(less common usage, like &environ, will cause a compilation error
rather than issue the nice warning, but the end result of informing
the developer about their portability problem is still achieved):
#if HAVE_RAW_DECL_ENVIRON
static char ***
rpl_environ (void) { return &environ; }
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
# undef environ
# define environ (*rpl_environ ())
#endif
or better (avoiding contradictory use of 'static' and 'extern'):
#if HAVE_RAW_DECL_ENVIRON
static char ***
_GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
rpl_environ (void) { return &environ; }
# undef environ
# define environ (*rpl_environ ())
#endif
*/
#ifndef _GL_WARN_ON_USE
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__warning__ (message)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# endif
#endif
/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
function is declared with the given prototype, consisting of return type,
parameters, and attributes.
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
not work in this case. */
#ifndef _GL_WARN_ON_USE_CXX
# if !defined __cplusplus
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_ON_USE (function, msg)
# else
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_clang function parameters_and_attributes \
__attribute__ ((__diagnose_if__ (1, msg, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif
# endif
#endif
/* _GL_WARN_EXTERN_C declaration;
performs the declaration with C linkage. */
#ifndef _GL_WARN_EXTERN_C
# if defined __cplusplus
# define _GL_WARN_EXTERN_C extern "C"
# else
# define _GL_WARN_EXTERN_C extern
# endif
#endif
/* Declare overridden functions. */
#if 0
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef creat
# define creat rpl_creat
# endif
_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode),
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
# elif defined _WIN32 && !defined __CYGWIN__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef creat
# define creat _creat
# endif
_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode));
# else
_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
# endif
_GL_CXXALIASWARN (creat);
#elif defined GNULIB_POSIXCHECK
# undef creat
/* Assume creat is always declared. */
_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
"use gnulib module creat for portability");
#elif 1
/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
required. In C++ with GNULIB_NAMESPACE, avoid differences between
platforms by defining GNULIB_NAMESPACE::creat always. */
# if defined _WIN32 && !defined __CYGWIN__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef creat
# define creat _creat
# endif
/* Need to cast, because in mingw the last argument is 'int mode'. */
_GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode));
# else
_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
# endif
_GL_CXXALIASWARN (creat);
#endif
#if 1
# if 1
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fcntl
# define fcntl rpl_fcntl
# endif
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...), );
_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
# if !GNULIB_defined_rpl_fcntl
# define GNULIB_defined_rpl_fcntl 1
# endif
# else
# if !1
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...), );
# if !GNULIB_defined_fcntl
# define GNULIB_defined_fcntl 1
# endif
# endif
_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
# endif
_GL_CXXALIASWARN (fcntl);
#elif defined GNULIB_POSIXCHECK
# undef fcntl
# if HAVE_RAW_DECL_FCNTL
_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
"use gnulib module fcntl for portability");
# endif
#endif
#if 1
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef open
# define open rpl_open
# endif
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
# elif defined _WIN32 && !defined __CYGWIN__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef open
# define open _open
# endif
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
# else
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
# endif
/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
default argument. _GL_CXXALIASWARN does not work in this case. */
# if !defined __hpux
_GL_CXXALIASWARN (open);
# endif
#elif defined GNULIB_POSIXCHECK
# undef open
/* Assume open is always declared. */
_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
"use gnulib module open for portability");
#elif 1
/* On native Windows, map 'open' to '_open', so that -loldnames is not
required. In C++ with GNULIB_NAMESPACE, avoid differences between
platforms by defining GNULIB_NAMESPACE::open always. */
# if defined _WIN32 && !defined __CYGWIN__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef open
# define open _open
# endif
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
# else
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
# endif
# if !defined __hpux
_GL_CXXALIASWARN (open);
# endif
#endif
#if IN_PARTED_GNULIB_TESTS
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef openat
# define openat rpl_openat
# endif
_GL_FUNCDECL_RPL (openat, int,
(int fd, char const *file, int flags, /* mode_t mode */ ...),
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (openat, int,
(int fd, char const *file, int flags, /* mode_t mode */ ...));
# else
# if !1
_GL_FUNCDECL_SYS (openat, int,
(int fd, char const *file, int flags, /* mode_t mode */ ...),
_GL_ARG_NONNULL ((2)));
# endif
_GL_CXXALIAS_SYS (openat, int,
(int fd, char const *file, int flags, /* mode_t mode */ ...));
# endif
_GL_CXXALIASWARN (openat);
#elif defined GNULIB_POSIXCHECK
# undef openat
# if HAVE_RAW_DECL_OPENAT
_GL_WARN_ON_USE (openat, "openat is not portable - "
"use gnulib module openat for portability");
# endif
#endif
/* Fix up the FD_* macros, only known to be missing on mingw. */
#ifndef FD_CLOEXEC
# define FD_CLOEXEC 1
#endif
/* Fix up the supported F_* macros. Intentionally leave other F_*
macros undefined. Only known to be missing on mingw. */
#ifndef F_DUPFD_CLOEXEC
# define F_DUPFD_CLOEXEC 0x40000000
/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
# define GNULIB_defined_F_DUPFD_CLOEXEC 1
#else
# define GNULIB_defined_F_DUPFD_CLOEXEC 0
#endif
#ifndef F_DUPFD
# define F_DUPFD 1
#endif
#ifndef F_GETFD
# define F_GETFD 2
#endif
/* Fix up the O_* macros. */
/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
to values outside 'int' range, so omit these misdefinitions.
But avoid namespace pollution on non-AIX systems. */
#ifdef _AIX
# include <limits.h>
# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
# undef O_CLOEXEC
# endif
# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
# undef O_NOFOLLOW
# endif
# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
# undef O_TTY_INIT
# endif
#endif
#if !defined O_DIRECT && defined O_DIRECTIO
/* Tru64 spells it 'O_DIRECTIO'. */
# define O_DIRECT O_DIRECTIO
#endif
#if !defined O_CLOEXEC && defined O_NOINHERIT
/* Mingw spells it 'O_NOINHERIT'. */
# define O_CLOEXEC O_NOINHERIT
#endif
#ifndef O_CLOEXEC
# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
# define GNULIB_defined_O_CLOEXEC 1
#else
# define GNULIB_defined_O_CLOEXEC 0
#endif
#ifndef O_DIRECT
# define O_DIRECT 0
#endif
#ifndef O_DIRECTORY
# define O_DIRECTORY 0
#endif
#ifndef O_DSYNC
# define O_DSYNC 0
#endif
#ifndef O_EXEC
# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
#endif
#ifndef O_IGNORE_CTTY
# define O_IGNORE_CTTY 0
#endif
#ifndef O_NDELAY
# define O_NDELAY 0
#endif
#ifndef O_NOATIME
# define O_NOATIME 0
#endif
#ifndef O_NONBLOCK
# define O_NONBLOCK O_NDELAY
#endif
/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
or to 0 as fallback. */
#if 0
# if O_NONBLOCK
# define GNULIB_defined_O_NONBLOCK 0
# else
# define GNULIB_defined_O_NONBLOCK 1
# undef O_NONBLOCK
# define O_NONBLOCK 0x40000000
# endif
#endif
#ifndef O_NOCTTY
# define O_NOCTTY 0
#endif
#ifndef O_NOFOLLOW
# define O_NOFOLLOW 0
#endif
#ifndef O_NOLINK
# define O_NOLINK 0
#endif
#ifndef O_NOLINKS
# define O_NOLINKS 0
#endif
#ifndef O_NOTRANS
# define O_NOTRANS 0
#endif
#ifndef O_RSYNC
# define O_RSYNC 0
#endif
#ifndef O_SEARCH
# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
#endif
#ifndef O_SYNC
# define O_SYNC 0
#endif
#ifndef O_TTY_INIT
# define O_TTY_INIT 0
#endif
#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
# undef O_ACCMODE
# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
#endif
/* For systems that distinguish between text and binary I/O.
O_BINARY is usually declared in fcntl.h */
#if !defined O_BINARY && defined _O_BINARY
/* For MSC-compatible compilers. */
# define O_BINARY _O_BINARY
# define O_TEXT _O_TEXT
#endif
#if defined __BEOS__ || defined __HAIKU__
/* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
# undef O_BINARY
# undef O_TEXT
#endif
#ifndef O_BINARY
# define O_BINARY 0
# define O_TEXT 0
#endif
/* Fix up the AT_* macros. */
/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
value exceeds INT_MAX, so its use as an int doesn't conform to the
C standard, and GCC and Sun C complain in some cases. If the bug
is present, undef AT_FDCWD here, so it can be redefined below. */
#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
# undef AT_FDCWD
#endif
/* Use the same bit pattern as Solaris 9, but with the proper
signedness. The bit pattern is important, in case this actually is
Solaris with the above workaround. */
#ifndef AT_FDCWD
# define AT_FDCWD (-3041965)
#endif
/* Use the same values as Solaris 9. This shouldn't matter, but
there's no real reason to differ. */
#ifndef AT_SYMLINK_NOFOLLOW
# define AT_SYMLINK_NOFOLLOW 4096
#endif
#ifndef AT_REMOVEDIR
# define AT_REMOVEDIR 1
#endif
/* Solaris 9 lacks these two, so just pick unique values. */
#ifndef AT_SYMLINK_FOLLOW
# define AT_SYMLINK_FOLLOW 2
#endif
#ifndef AT_EACCESS
# define AT_EACCESS 4
#endif
/* Ignore this flag if not supported. */
#ifndef AT_NO_AUTOMOUNT
# define AT_NO_AUTOMOUNT 0
#endif
#endif /* _GL_FCNTL_H */
#endif /* _GL_FCNTL_H */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,740 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Substitute for and wrapper around <langinfo.h>.
Copyright (C) 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/*
* POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
* <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
*/
#ifndef _GL_LANGINFO_H
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
/* The include_next requires a split double-inclusion guard. */
#if 1
# include_next <langinfo.h>
#endif
#ifndef _GL_LANGINFO_H
#define _GL_LANGINFO_H
/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
#if !1
/* A platform that lacks <langinfo.h>. */
/* Assume that it also lacks <nl_types.h> and the nl_item type. */
# if !GNULIB_defined_nl_item
typedef int nl_item;
# define GNULIB_defined_nl_item 1
# endif
/* nl_langinfo items of the LC_CTYPE category */
# define CODESET 10000
/* nl_langinfo items of the LC_NUMERIC category */
# define RADIXCHAR 10001
# define DECIMAL_POINT RADIXCHAR
# define THOUSEP 10002
# define THOUSANDS_SEP THOUSEP
# define GROUPING 10114
/* nl_langinfo items of the LC_TIME category */
# define D_T_FMT 10003
# define D_FMT 10004
# define T_FMT 10005
# define T_FMT_AMPM 10006
# define AM_STR 10007
# define PM_STR 10008
# define DAY_1 10009
# define DAY_2 (DAY_1 + 1)
# define DAY_3 (DAY_1 + 2)
# define DAY_4 (DAY_1 + 3)
# define DAY_5 (DAY_1 + 4)
# define DAY_6 (DAY_1 + 5)
# define DAY_7 (DAY_1 + 6)
# define ABDAY_1 10016
# define ABDAY_2 (ABDAY_1 + 1)
# define ABDAY_3 (ABDAY_1 + 2)
# define ABDAY_4 (ABDAY_1 + 3)
# define ABDAY_5 (ABDAY_1 + 4)
# define ABDAY_6 (ABDAY_1 + 5)
# define ABDAY_7 (ABDAY_1 + 6)
# define MON_1 10023
# define MON_2 (MON_1 + 1)
# define MON_3 (MON_1 + 2)
# define MON_4 (MON_1 + 3)
# define MON_5 (MON_1 + 4)
# define MON_6 (MON_1 + 5)
# define MON_7 (MON_1 + 6)
# define MON_8 (MON_1 + 7)
# define MON_9 (MON_1 + 8)
# define MON_10 (MON_1 + 9)
# define MON_11 (MON_1 + 10)
# define MON_12 (MON_1 + 11)
# define ALTMON_1 10200
# define ALTMON_2 (ALTMON_1 + 1)
# define ALTMON_3 (ALTMON_1 + 2)
# define ALTMON_4 (ALTMON_1 + 3)
# define ALTMON_5 (ALTMON_1 + 4)
# define ALTMON_6 (ALTMON_1 + 5)
# define ALTMON_7 (ALTMON_1 + 6)
# define ALTMON_8 (ALTMON_1 + 7)
# define ALTMON_9 (ALTMON_1 + 8)
# define ALTMON_10 (ALTMON_1 + 9)
# define ALTMON_11 (ALTMON_1 + 10)
# define ALTMON_12 (ALTMON_1 + 11)
# define ABMON_1 10035
# define ABMON_2 (ABMON_1 + 1)
# define ABMON_3 (ABMON_1 + 2)
# define ABMON_4 (ABMON_1 + 3)
# define ABMON_5 (ABMON_1 + 4)
# define ABMON_6 (ABMON_1 + 5)
# define ABMON_7 (ABMON_1 + 6)
# define ABMON_8 (ABMON_1 + 7)
# define ABMON_9 (ABMON_1 + 8)
# define ABMON_10 (ABMON_1 + 9)
# define ABMON_11 (ABMON_1 + 10)
# define ABMON_12 (ABMON_1 + 11)
# define ERA 10047
# define ERA_D_FMT 10048
# define ERA_D_T_FMT 10049
# define ERA_T_FMT 10050
# define ALT_DIGITS 10051
/* nl_langinfo items of the LC_MONETARY category */
# define CRNCYSTR 10052
# define CURRENCY_SYMBOL CRNCYSTR
# define INT_CURR_SYMBOL 10100
# define MON_DECIMAL_POINT 10101
# define MON_THOUSANDS_SEP 10102
# define MON_GROUPING 10103
# define POSITIVE_SIGN 10104
# define NEGATIVE_SIGN 10105
# define FRAC_DIGITS 10106
# define INT_FRAC_DIGITS 10107
# define P_CS_PRECEDES 10108
# define N_CS_PRECEDES 10109
# define P_SEP_BY_SPACE 10110
# define N_SEP_BY_SPACE 10111
# define P_SIGN_POSN 10112
# define N_SIGN_POSN 10113
/* nl_langinfo items of the LC_MESSAGES category */
# define YESEXPR 10053
# define NOEXPR 10054
#else
/* A platform that has <langinfo.h>. */
# if !1
# define CODESET 10000
# define GNULIB_defined_CODESET 1
# endif
# if !1
# define T_FMT_AMPM 10006
# define GNULIB_defined_T_FMT_AMPM 1
# endif
# if !0
# define ALTMON_1 10200
# define ALTMON_2 (ALTMON_1 + 1)
# define ALTMON_3 (ALTMON_1 + 2)
# define ALTMON_4 (ALTMON_1 + 3)
# define ALTMON_5 (ALTMON_1 + 4)
# define ALTMON_6 (ALTMON_1 + 5)
# define ALTMON_7 (ALTMON_1 + 6)
# define ALTMON_8 (ALTMON_1 + 7)
# define ALTMON_9 (ALTMON_1 + 8)
# define ALTMON_10 (ALTMON_1 + 9)
# define ALTMON_11 (ALTMON_1 + 10)
# define ALTMON_12 (ALTMON_1 + 11)
# define GNULIB_defined_ALTMON 1
# endif
# if !1
# define ERA 10047
# define ERA_D_FMT 10048
# define ERA_D_T_FMT 10049
# define ERA_T_FMT 10050
# define ALT_DIGITS 10051
# define GNULIB_defined_ERA 1
# endif
# if !1
# define YESEXPR 10053
# define NOEXPR 10054
# define GNULIB_defined_YESEXPR 1
# endif
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* C++ compatible function declaration macros.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
/* Begin/end the GNULIB_NAMESPACE namespace. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif
/* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some
platforms, but is declared and works fine on the platforms on which
it exists:
#if @GNULIB_FOO@
# if !@HAVE_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on all platforms,
but is broken/insufficient and needs to be replaced on some platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on some platforms
but is broken/insufficient and needs to be replaced on some of them and
is additionally either missing or undeclared on some other platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
# if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
*/
/* _GL_EXTERN_C declaration;
performs the declaration with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C extern "C"
#else
# define _GL_EXTERN_C extern
#endif
/* _GL_EXTERN_C_FUNC declaration;
performs the declaration of a function with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C_FUNC extern "C"
#else
/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
are not allowed between 'extern' and the return type (see gnulib-common.m4).
*/
# define _GL_EXTERN_C_FUNC
#endif
/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
declares a replacement function, named rpl_func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
_GL_ARG_NONNULL ((1)));
Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
because
[[...]] extern "C" <declaration>;
is invalid syntax in C++.)
*/
#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
declares the system function, named func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
*/
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
Wrapping rpl_func in an object with an inline conversion operator
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::rpl_func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
is to be used when func is a Microsoft deprecated alias, on native Windows.
It declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to _func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
*/
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
except that the C function rpl_func may have a slightly different
declaration. A cast is used to silence the "invalid conversion" error
that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::rpl_func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
Wrapping func in an object with an inline conversion operator
avoids a reference to func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function is picked among a set of overloaded functions,
namely the one with rettype2 and parameters2. Two consecutive casts
are used to silence the "cannot find a match" and "invalid conversion"
errors that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
/* The outer cast must be a reinterpret_cast.
The inner cast: When the function is defined as a set of overloaded
functions, it works as a static_cast<>, choosing the designated variant.
When the function is defined as a single variant, it works as a
reinterpret_cast<>. The parenthesized cast syntax works both ways. */
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN (func);
causes a warning to be emitted when ::func is used but not when
GNULIB_NAMESPACE::func is used. func must be defined without overloaded
variants. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN(func) \
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN_2(func,namespace) \
extern __typeof__ (func) func
# else
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN(func) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
causes a warning to be emitted when the given overloaded variant of ::func
is used but not when GNULIB_NAMESPACE::func is used. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# else
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
#endif /* _GL_CXXDEFS_H */
/* The definition of _GL_WARN_ON_USE is copied here. */
/* A C macro for emitting warnings if a function is used.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
for FUNCTION which will then trigger a compiler warning containing
the text of "literal string" anywhere that function is called, if
supported by the compiler. If the compiler does not support this
feature, the macro expands to an unused extern declaration.
_GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
attribute used in _GL_WARN_ON_USE. If the compiler does not support
this feature, it expands to empty.
These macros are useful for marking a function as a potential
portability trap, with the intent that "literal string" include
instructions on the replacement function that should be used
instead.
_GL_WARN_ON_USE is for functions with 'extern' linkage.
_GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
linkage.
_GL_WARN_ON_USE should not be used more than once for a given function
in a given compilation unit (because this may generate a warning even
if the function is never called).
However, one of the reasons that a function is a portability trap is
if it has the wrong signature. Declaring FUNCTION with a different
signature in C is a compilation error, so this macro must use the
same type as any existing declaration so that programs that avoid
the problematic FUNCTION do not fail to compile merely because they
included a header that poisoned the function. But this implies that
_GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
have a declaration. Use of this macro implies that there must not
be any other macro hiding the declaration of FUNCTION; but
undefining FUNCTION first is part of the poisoning process anyway
(although for symbols that are provided only via a macro, the result
is a compilation error rather than a warning containing
"literal string"). Also note that in C++, it is only safe to use if
FUNCTION has no overloads.
For an example, it is possible to poison 'getline' by:
- adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
[getline]) in configure.ac, which potentially defines
HAVE_RAW_DECL_GETLINE
- adding this code to a header that wraps the system <stdio.h>:
#undef getline
#if HAVE_RAW_DECL_GETLINE
_GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
"not universally present; use the gnulib module getline");
#endif
It is not possible to directly poison global variables. But it is
possible to write a wrapper accessor function, and poison that
(less common usage, like &environ, will cause a compilation error
rather than issue the nice warning, but the end result of informing
the developer about their portability problem is still achieved):
#if HAVE_RAW_DECL_ENVIRON
static char ***
rpl_environ (void) { return &environ; }
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
# undef environ
# define environ (*rpl_environ ())
#endif
or better (avoiding contradictory use of 'static' and 'extern'):
#if HAVE_RAW_DECL_ENVIRON
static char ***
_GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
rpl_environ (void) { return &environ; }
# undef environ
# define environ (*rpl_environ ())
#endif
*/
#ifndef _GL_WARN_ON_USE
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__warning__ (message)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# endif
#endif
/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
function is declared with the given prototype, consisting of return type,
parameters, and attributes.
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
not work in this case. */
#ifndef _GL_WARN_ON_USE_CXX
# if !defined __cplusplus
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_ON_USE (function, msg)
# else
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_clang function parameters_and_attributes \
__attribute__ ((__diagnose_if__ (1, msg, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif
# endif
#endif
/* _GL_WARN_EXTERN_C declaration;
performs the declaration with C linkage. */
#ifndef _GL_WARN_EXTERN_C
# if defined __cplusplus
# define _GL_WARN_EXTERN_C extern "C"
# else
# define _GL_WARN_EXTERN_C extern
# endif
#endif
/* Declare overridden functions. */
/* Return a piece of locale dependent information.
Note: The difference between nl_langinfo (CODESET) and locale_charset ()
is that the latter normalizes the encoding names to GNU conventions. */
#if 1
# if 1
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef nl_langinfo
# define nl_langinfo rpl_nl_langinfo
# endif
_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item), );
_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item));
# else
# if !1
_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item), );
# endif
_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (nl_langinfo);
# endif
#elif defined GNULIB_POSIXCHECK
# undef nl_langinfo
# if HAVE_RAW_DECL_NL_LANGINFO
_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
"use gnulib module nl_langinfo for portability");
# endif
#endif
#endif /* _GL_LANGINFO_H */
#endif /* _GL_LANGINFO_H */

View File

@@ -1,152 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A GNU-like <limits.h>.
Copyright 2016-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
#if defined _GL_ALREADY_INCLUDING_LIMITS_H
/* Special invocation convention:
On Haiku/x86_64, we have a sequence of nested includes
<limits.h> -> <syslimits.h> -> <limits.h>.
In this situation, LONG_MAX and INT_MAX are not yet defined,
therefore we should not attempt to define LONG_BIT. */
#include_next <limits.h>
#else
/* Normal invocation convention. */
#ifndef _GL_LIMITS_H
# define _GL_ALREADY_INCLUDING_LIMITS_H
/* The include_next requires a split double-inclusion guard. */
# include_next <limits.h>
# undef _GL_ALREADY_INCLUDING_LIMITS_H
#ifndef _GL_LIMITS_H
#define _GL_LIMITS_H
#ifndef LLONG_MIN
# if defined LONG_LONG_MIN /* HP-UX 11.31 */
# define LLONG_MIN LONG_LONG_MIN
# elif defined LONGLONG_MIN /* IRIX 6.5 */
# define LLONG_MIN LONGLONG_MIN
# elif defined __GNUC__
# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
# endif
#endif
#ifndef LLONG_MAX
# if defined LONG_LONG_MAX /* HP-UX 11.31 */
# define LLONG_MAX LONG_LONG_MAX
# elif defined LONGLONG_MAX /* IRIX 6.5 */
# define LLONG_MAX LONGLONG_MAX
# elif defined __GNUC__
# define LLONG_MAX __LONG_LONG_MAX__
# endif
#endif
#ifndef ULLONG_MAX
# if defined ULONG_LONG_MAX /* HP-UX 11.31 */
# define ULLONG_MAX ULONG_LONG_MAX
# elif defined ULONGLONG_MAX /* IRIX 6.5 */
# define ULLONG_MAX ULONGLONG_MAX
# elif defined __GNUC__
# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
# endif
#endif
/* The number of usable bits in an unsigned or signed integer type
with minimum value MIN and maximum value MAX, as an int expression
suitable in #if. Cover all known practical hosts. This
implementation exploits the fact that MAX is 1 less than a power of
2, and merely counts the number of 1 bits in MAX; "COBn" means
"count the number of 1 bits in the low-order n bits"). */
#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
#ifndef WORD_BIT
/* Assume 'int' is 32 bits wide. */
# define WORD_BIT 32
#endif
#ifndef LONG_BIT
/* Assume 'long' is 32 or 64 bits wide. */
# if LONG_MAX == INT_MAX
# define LONG_BIT 32
# else
# define LONG_BIT 64
# endif
#endif
/* Assume no multibyte character is longer than 16 bytes. */
#ifndef MB_LEN_MAX
# define MB_LEN_MAX 16
#endif
/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */
#if (! defined ULLONG_WIDTH \
&& (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \
|| (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
#endif
/* Macros specified by C23. */
#if (defined _GNU_SOURCE \
|| (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
# if ! defined BOOL_WIDTH
# define BOOL_WIDTH 1
# define BOOL_MAX 1
# elif ! defined BOOL_MAX
# define BOOL_MAX 1
# endif
#endif
/* Macro specified by POSIX. */
/* The maximum ssize_t value. Although it might not be of ssize_t type
as it should be, it's too much trouble to fix this minor detail. */
#ifndef SSIZE_MAX
# ifdef _WIN64
# define SSIZE_MAX LLONG_MAX
# else
# define SSIZE_MAX LONG_MAX
# endif
#endif
#endif /* _GL_LIMITS_H */
#endif /* _GL_LIMITS_H */
#endif

View File

@@ -1,849 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A POSIX <locale.h>.
Copyright (C) 2007-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
|| defined _GL_ALREADY_INCLUDING_LOCALE_H
/* Special invocation convention:
- Inside mingw header files,
- To handle Solaris header files (through Solaris 10) when combined
with gettext's libintl.h. */
#include_next <locale.h>
#else
/* Normal invocation convention. */
#ifndef _GL_LOCALE_H
#define _GL_ALREADY_INCLUDING_LOCALE_H
/* The include_next requires a split double-inclusion guard. */
#include_next <locale.h>
#undef _GL_ALREADY_INCLUDING_LOCALE_H
#ifndef _GL_LOCALE_H
#define _GL_LOCALE_H
/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
#if 1
# include <xlocale.h>
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* C++ compatible function declaration macros.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
/* Begin/end the GNULIB_NAMESPACE namespace. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif
/* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some
platforms, but is declared and works fine on the platforms on which
it exists:
#if @GNULIB_FOO@
# if !@HAVE_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on all platforms,
but is broken/insufficient and needs to be replaced on some platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on some platforms
but is broken/insufficient and needs to be replaced on some of them and
is additionally either missing or undeclared on some other platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
# if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
*/
/* _GL_EXTERN_C declaration;
performs the declaration with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C extern "C"
#else
# define _GL_EXTERN_C extern
#endif
/* _GL_EXTERN_C_FUNC declaration;
performs the declaration of a function with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C_FUNC extern "C"
#else
/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
are not allowed between 'extern' and the return type (see gnulib-common.m4).
*/
# define _GL_EXTERN_C_FUNC
#endif
/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
declares a replacement function, named rpl_func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
_GL_ARG_NONNULL ((1)));
Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
because
[[...]] extern "C" <declaration>;
is invalid syntax in C++.)
*/
#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
declares the system function, named func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
*/
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
Wrapping rpl_func in an object with an inline conversion operator
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::rpl_func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
is to be used when func is a Microsoft deprecated alias, on native Windows.
It declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to _func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
*/
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
except that the C function rpl_func may have a slightly different
declaration. A cast is used to silence the "invalid conversion" error
that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::rpl_func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
Wrapping func in an object with an inline conversion operator
avoids a reference to func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function is picked among a set of overloaded functions,
namely the one with rettype2 and parameters2. Two consecutive casts
are used to silence the "cannot find a match" and "invalid conversion"
errors that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
/* The outer cast must be a reinterpret_cast.
The inner cast: When the function is defined as a set of overloaded
functions, it works as a static_cast<>, choosing the designated variant.
When the function is defined as a single variant, it works as a
reinterpret_cast<>. The parenthesized cast syntax works both ways. */
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN (func);
causes a warning to be emitted when ::func is used but not when
GNULIB_NAMESPACE::func is used. func must be defined without overloaded
variants. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN(func) \
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN_2(func,namespace) \
extern __typeof__ (func) func
# else
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN(func) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
causes a warning to be emitted when the given overloaded variant of ::func
is used but not when GNULIB_NAMESPACE::func is used. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# else
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
#endif /* _GL_CXXDEFS_H */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers.
n = 1 stands for the first argument, n = 2 for the second argument etc. */
#ifndef _GL_ARG_NONNULL
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
# else
# define _GL_ARG_NONNULL(params)
# endif
#endif
/* The definition of _GL_WARN_ON_USE is copied here. */
/* A C macro for emitting warnings if a function is used.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
for FUNCTION which will then trigger a compiler warning containing
the text of "literal string" anywhere that function is called, if
supported by the compiler. If the compiler does not support this
feature, the macro expands to an unused extern declaration.
_GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
attribute used in _GL_WARN_ON_USE. If the compiler does not support
this feature, it expands to empty.
These macros are useful for marking a function as a potential
portability trap, with the intent that "literal string" include
instructions on the replacement function that should be used
instead.
_GL_WARN_ON_USE is for functions with 'extern' linkage.
_GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
linkage.
_GL_WARN_ON_USE should not be used more than once for a given function
in a given compilation unit (because this may generate a warning even
if the function is never called).
However, one of the reasons that a function is a portability trap is
if it has the wrong signature. Declaring FUNCTION with a different
signature in C is a compilation error, so this macro must use the
same type as any existing declaration so that programs that avoid
the problematic FUNCTION do not fail to compile merely because they
included a header that poisoned the function. But this implies that
_GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
have a declaration. Use of this macro implies that there must not
be any other macro hiding the declaration of FUNCTION; but
undefining FUNCTION first is part of the poisoning process anyway
(although for symbols that are provided only via a macro, the result
is a compilation error rather than a warning containing
"literal string"). Also note that in C++, it is only safe to use if
FUNCTION has no overloads.
For an example, it is possible to poison 'getline' by:
- adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
[getline]) in configure.ac, which potentially defines
HAVE_RAW_DECL_GETLINE
- adding this code to a header that wraps the system <stdio.h>:
#undef getline
#if HAVE_RAW_DECL_GETLINE
_GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
"not universally present; use the gnulib module getline");
#endif
It is not possible to directly poison global variables. But it is
possible to write a wrapper accessor function, and poison that
(less common usage, like &environ, will cause a compilation error
rather than issue the nice warning, but the end result of informing
the developer about their portability problem is still achieved):
#if HAVE_RAW_DECL_ENVIRON
static char ***
rpl_environ (void) { return &environ; }
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
# undef environ
# define environ (*rpl_environ ())
#endif
or better (avoiding contradictory use of 'static' and 'extern'):
#if HAVE_RAW_DECL_ENVIRON
static char ***
_GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
rpl_environ (void) { return &environ; }
# undef environ
# define environ (*rpl_environ ())
#endif
*/
#ifndef _GL_WARN_ON_USE
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__warning__ (message)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# endif
#endif
/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
function is declared with the given prototype, consisting of return type,
parameters, and attributes.
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
not work in this case. */
#ifndef _GL_WARN_ON_USE_CXX
# if !defined __cplusplus
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_ON_USE (function, msg)
# else
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_clang function parameters_and_attributes \
__attribute__ ((__diagnose_if__ (1, msg, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif
# endif
#endif
/* _GL_WARN_EXTERN_C declaration;
performs the declaration with C linkage. */
#ifndef _GL_WARN_EXTERN_C
# if defined __cplusplus
# define _GL_WARN_EXTERN_C extern "C"
# else
# define _GL_WARN_EXTERN_C extern
# endif
#endif
/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
On systems that don't define it, use the same value as GNU libintl. */
#if !defined LC_MESSAGES
# define LC_MESSAGES 1729
#endif
/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
int_n_*. Instead of overriding 'struct lconv', merely define these member
names as macros. This avoids trouble in C++ mode. */
#if defined _MSC_VER
# define int_p_cs_precedes p_cs_precedes
# define int_p_sign_posn p_sign_posn
# define int_p_sep_by_space p_sep_by_space
# define int_n_cs_precedes n_cs_precedes
# define int_n_sign_posn n_sign_posn
# define int_n_sep_by_space n_sep_by_space
#endif
/* Bionic libc's 'struct lconv' is just a dummy. */
#if 0
# define lconv rpl_lconv
struct lconv
{
/* All 'char *' are actually 'const char *'. */
/* Members that depend on the LC_NUMERIC category of the locale. See
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
/* Symbol used as decimal point. */
char *decimal_point;
/* Symbol used to separate groups of digits to the left of the decimal
point. */
char *thousands_sep;
/* Definition of the size of groups of digits to the left of the decimal
point. */
char *grouping;
/* Members that depend on the LC_MONETARY category of the locale. See
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
/* Symbol used as decimal point. */
char *mon_decimal_point;
/* Symbol used to separate groups of digits to the left of the decimal
point. */
char *mon_thousands_sep;
/* Definition of the size of groups of digits to the left of the decimal
point. */
char *mon_grouping;
/* Sign used to indicate a value >= 0. */
char *positive_sign;
/* Sign used to indicate a value < 0. */
char *negative_sign;
/* For formatting local currency. */
/* Currency symbol (3 characters) followed by separator (1 character). */
char *currency_symbol;
/* Number of digits after the decimal point. */
char frac_digits;
/* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char p_cs_precedes;
/* For values >= 0: Position of the sign. */
char p_sign_posn;
/* For values >= 0: Placement of spaces between currency symbol, sign, and
number. */
char p_sep_by_space;
/* For values < 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char n_cs_precedes;
/* For values < 0: Position of the sign. */
char n_sign_posn;
/* For values < 0: Placement of spaces between currency symbol, sign, and
number. */
char n_sep_by_space;
/* For formatting international currency. */
/* Currency symbol (3 characters) followed by separator (1 character). */
char *int_curr_symbol;
/* Number of digits after the decimal point. */
char int_frac_digits;
/* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char int_p_cs_precedes;
/* For values >= 0: Position of the sign. */
char int_p_sign_posn;
/* For values >= 0: Placement of spaces between currency symbol, sign, and
number. */
char int_p_sep_by_space;
/* For values < 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char int_n_cs_precedes;
/* For values < 0: Position of the sign. */
char int_n_sign_posn;
/* For values < 0: Placement of spaces between currency symbol, sign, and
number. */
char int_n_sep_by_space;
};
#endif
#if 1
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef localeconv
# define localeconv rpl_localeconv
# endif
_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void), );
_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
# else
_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (localeconv);
# endif
#elif 0
# if !GNULIB_LOCALECONV
# undef localeconv
# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
# endif
#elif defined GNULIB_POSIXCHECK
# undef localeconv
# if HAVE_RAW_DECL_LOCALECONV
_GL_WARN_ON_USE (localeconv,
"localeconv returns too few information on some platforms - "
"use gnulib module localeconv for portability");
# endif
#endif
#if IN_PARTED_GNULIB_TESTS
# if 1
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef setlocale
# define setlocale rpl_setlocale
# define GNULIB_defined_setlocale 1
# endif
_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale), );
_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
# else
_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (setlocale);
# endif
#elif defined GNULIB_POSIXCHECK
# undef setlocale
# if HAVE_RAW_DECL_SETLOCALE
_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
"use gnulib module setlocale for portability");
# endif
#endif
#if 1
/* Included here for convenience. */
# include "setlocale_null.h"
#endif
#if /*@GNULIB_NEWLOCALE@ ||*/ (IN_PARTED_GNULIB_TESTS && 0 && 1)
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef newlocale
# define newlocale rpl_newlocale
# define GNULIB_defined_newlocale 1
# endif
_GL_FUNCDECL_RPL (newlocale, locale_t,
(int category_mask, const char *name, locale_t base),
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (newlocale, locale_t,
(int category_mask, const char *name, locale_t base));
# else
# if 1
_GL_CXXALIAS_SYS (newlocale, locale_t,
(int category_mask, const char *name, locale_t base));
# endif
# endif
# if __GLIBC__ >= 2 && 1
_GL_CXXALIASWARN (newlocale);
# endif
# if 1 || 0
# ifndef HAVE_WORKING_NEWLOCALE
# define HAVE_WORKING_NEWLOCALE 1
# endif
# endif
#elif defined GNULIB_POSIXCHECK
# undef newlocale
# if HAVE_RAW_DECL_NEWLOCALE
_GL_WARN_ON_USE (newlocale, "newlocale is not portable");
# endif
#endif
#if 0 || (IN_PARTED_GNULIB_TESTS && 0 && 1)
# if 1 /* locale_t may be undefined if !1. */
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef duplocale
# define duplocale rpl_duplocale
# define GNULIB_defined_duplocale 1
# endif
_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
# else
_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
# endif
# endif
# if __GLIBC__ >= 2 && 1
_GL_CXXALIASWARN (duplocale);
# endif
# if 1
# ifndef HAVE_WORKING_DUPLOCALE
# define HAVE_WORKING_DUPLOCALE 1
# endif
# endif
#elif defined GNULIB_POSIXCHECK
# undef duplocale
# if HAVE_RAW_DECL_DUPLOCALE
_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
"use gnulib module duplocale for portability");
# endif
#endif
#if /*@GNULIB_FREELOCALE@ ||*/ (IN_PARTED_GNULIB_TESTS && 0 && 1)
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef freelocale
# define freelocale rpl_freelocale
# define GNULIB_defined_freelocale 1
# endif
_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
# else
# if 1
/* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
int. */
_GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
# endif
# endif
# if __GLIBC__ >= 2 && 1
_GL_CXXALIASWARN (freelocale);
# endif
#elif defined GNULIB_POSIXCHECK
# undef freelocale
# if HAVE_RAW_DECL_FREELOCALE
_GL_WARN_ON_USE (freelocale, "freelocale is not portable");
# endif
#endif
#endif /* _GL_LOCALE_H */
#endif /* _GL_LOCALE_H */
#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */

View File

@@ -1,529 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Type-safe arrays which grow dynamically.
Copyright (C) 2017-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* Pre-processor macros which act as parameters:
DYNARRAY_STRUCT
The struct tag of dynamic array to be defined.
DYNARRAY_ELEMENT
The type name of the element type. Elements are copied
as if by memcpy, and can change address as the dynamic
array grows.
DYNARRAY_PREFIX
The prefix of the functions which are defined.
The following parameters are optional:
DYNARRAY_ELEMENT_FREE
DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
contents of elements. E is of type DYNARRAY_ELEMENT *.
DYNARRAY_ELEMENT_INIT
DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
element. E is of type DYNARRAY_ELEMENT *.
If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
defined, new elements are automatically zero-initialized.
Otherwise, new elements have undefined contents.
DYNARRAY_INITIAL_SIZE
The size of the statically allocated array (default:
at least 2, more elements if they fit into 128 bytes).
Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
there is no statically allocated array at, and all non-empty
arrays are heap-allocated.
DYNARRAY_FINAL_TYPE
The name of the type which holds the final array. If not
defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
must be a struct type, with members of type DYNARRAY_ELEMENT and
size_t at the start (in this order).
These macros are undefined after this header file has been
included.
The following types are provided (their members are private to the
dynarray implementation):
struct DYNARRAY_STRUCT
The following functions are provided:
void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *);
bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *);
size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t);
void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *);
bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t);
void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *);
The following functions are provided are provided if the
prerequisites are met:
bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
DYNARRAY_FINAL_TYPE *);
(if DYNARRAY_FINAL_TYPE is defined)
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
size_t *);
(if DYNARRAY_FINAL_TYPE is not defined)
*/
#include <malloc/dynarray.gl.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#ifndef DYNARRAY_STRUCT
# error "DYNARRAY_STRUCT must be defined"
#endif
#ifndef DYNARRAY_ELEMENT
# error "DYNARRAY_ELEMENT must be defined"
#endif
#ifndef DYNARRAY_PREFIX
# error "DYNARRAY_PREFIX must be defined"
#endif
#ifdef DYNARRAY_INITIAL_SIZE
# if DYNARRAY_INITIAL_SIZE < 0
# error "DYNARRAY_INITIAL_SIZE must be non-negative"
# endif
# if DYNARRAY_INITIAL_SIZE > 0
# define DYNARRAY_HAVE_SCRATCH 1
# else
# define DYNARRAY_HAVE_SCRATCH 0
# endif
#else
/* Provide a reasonable default which limits the size of
DYNARRAY_STRUCT. */
# define DYNARRAY_INITIAL_SIZE \
(sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT))
# define DYNARRAY_HAVE_SCRATCH 1
#endif
/* Public type definitions. */
/* All fields of this struct are private to the implementation. */
struct DYNARRAY_STRUCT
{
union
{
struct dynarray_header dynarray_abstract;
struct
{
/* These fields must match struct dynarray_header. */
size_t used;
size_t allocated;
DYNARRAY_ELEMENT *array;
} dynarray_header;
} u;
#if DYNARRAY_HAVE_SCRATCH
/* Initial inline allocation. */
DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE];
#endif
};
/* Internal use only: Helper macros. */
/* Ensure macro-expansion of DYNARRAY_PREFIX. */
#define DYNARRAY_CONCAT0(prefix, name) prefix##name
#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
so that Gnulib does not change 'free' to 'rpl_free'. */
#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
/* Address of the scratch buffer if any. */
#if DYNARRAY_HAVE_SCRATCH
# define DYNARRAY_SCRATCH(list) (list)->scratch
#else
# define DYNARRAY_SCRATCH(list) NULL
#endif
/* Internal use only: Helper functions. */
/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array
elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE
macro expansion. */
static inline void
DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
size_t __dynarray_used)
{
#ifdef DYNARRAY_ELEMENT_FREE
for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i)
DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]);
#endif /* DYNARRAY_ELEMENT_FREE */
}
/* Internal function. Free the non-scratch array allocation. */
static inline void
DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
{
#if DYNARRAY_HAVE_SCRATCH
if (list->u.dynarray_header.array != list->scratch)
free (list->u.dynarray_header.array);
#else
free (list->u.dynarray_header.array);
#endif
}
/* Public functions. */
/* Initialize a dynamic array object. This must be called before any
use of the object. */
_GL_ATTRIBUTE_NONNULL ((1))
static void
DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
{
list->u.dynarray_header.used = 0;
list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE;
list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
}
/* Deallocate the dynamic array and its elements. */
_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
static void
DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
DYNARRAY_NAME (free__array__) (list);
DYNARRAY_NAME (init) (list);
}
/* Return true if the dynamic array is in an error state. */
_GL_ATTRIBUTE_NONNULL ((1))
static inline bool
DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.allocated == __dynarray_error_marker ();
}
/* Mark the dynamic array as failed. All elements are deallocated as
a side effect. */
_GL_ATTRIBUTE_NONNULL ((1))
static void
DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
DYNARRAY_NAME (free__array__) (list);
list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
list->u.dynarray_header.used = 0;
list->u.dynarray_header.allocated = __dynarray_error_marker ();
}
/* Return the number of elements which have been added to the dynamic
array. */
_GL_ATTRIBUTE_NONNULL ((1))
static inline size_t
DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.used;
}
/* Return a pointer to the array element at INDEX. Terminate the
process if INDEX is out of bounds. */
_GL_ATTRIBUTE_NONNULL ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
{
if (_GL_UNLIKELY (index >= DYNARRAY_NAME (size) (list)))
__libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index);
return list->u.dynarray_header.array + index;
}
/* Return a pointer to the first array element, if any. For a
zero-length array, the pointer can be NULL even though the dynamic
array has not entered the failure state. */
_GL_ATTRIBUTE_NONNULL ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.array;
}
/* Return a pointer one element past the last array element. For a
zero-length array, the pointer can be NULL even though the dynamic
array has not entered the failure state. */
_GL_ATTRIBUTE_NONNULL ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.array + list->u.dynarray_header.used;
}
/* Internal function. Slow path for the add function below. */
static void
DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
{
if (_GL_UNLIKELY
(!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT))))
{
DYNARRAY_NAME (mark_failed) (list);
return;
}
/* Copy the new element and increase the array length. */
list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
}
/* Add ITEM at the end of the array, enlarging it by one element.
Mark *LIST as failed if the dynamic array allocation size cannot be
increased. */
_GL_ATTRIBUTE_NONNULL ((1))
static inline void
DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
{
/* Do nothing in case of previous error. */
if (DYNARRAY_NAME (has_failed) (list))
return;
/* Enlarge the array if necessary. */
if (_GL_UNLIKELY (list->u.dynarray_header.used
== list->u.dynarray_header.allocated))
{
DYNARRAY_NAME (add__) (list, item);
return;
}
/* Copy the new element and increase the array length. */
list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
}
/* Internal function. Building block for the emplace functions below.
Assumes space for one more element in *LIST. */
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_ELEMENT *result
= &list->u.dynarray_header.array[list->u.dynarray_header.used];
++list->u.dynarray_header.used;
#if defined (DYNARRAY_ELEMENT_INIT)
DYNARRAY_ELEMENT_INIT (result);
#elif defined (DYNARRAY_ELEMENT_FREE)
memset (result, 0, sizeof (*result));
#endif
return result;
}
/* Internal function. Slow path for the emplace function below. */
static DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
{
if (_GL_UNLIKELY
(!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT))))
{
DYNARRAY_NAME (mark_failed) (list);
return NULL;
}
return DYNARRAY_NAME (emplace__tail__) (list);
}
/* Allocate a place for a new element in *LIST and return a pointer to
it. The pointer can be NULL if the dynamic array cannot be
enlarged due to a memory allocation failure. */
_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
_GL_ATTRIBUTE_NONNULL ((1))
static
/* Avoid inlining with the larger initialization code. */
#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
inline
#endif
DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
{
/* Do nothing in case of previous error. */
if (DYNARRAY_NAME (has_failed) (list))
return NULL;
/* Enlarge the array if necessary. */
if (_GL_UNLIKELY (list->u.dynarray_header.used
== list->u.dynarray_header.allocated))
return (DYNARRAY_NAME (emplace__) (list));
return DYNARRAY_NAME (emplace__tail__) (list);
}
/* Change the size of *LIST to SIZE. If SIZE is larger than the
existing size, new elements are added (which can be initialized).
Otherwise, the list is truncated, and elements are freed. Return
false on memory allocation failure (and mark *LIST as failed). */
_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
static bool
DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
{
if (size > list->u.dynarray_header.used)
{
bool ok;
#if defined (DYNARRAY_ELEMENT_INIT)
/* The new elements have to be initialized. */
size_t old_size = list->u.dynarray_header.used;
ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
size, DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT));
if (ok)
for (size_t i = old_size; i < size; ++i)
{
DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
}
#elif defined (DYNARRAY_ELEMENT_FREE)
/* Zero initialization is needed so that the elements can be
safely freed. */
ok = __libc_dynarray_resize_clear
(&list->u.dynarray_abstract, size,
DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT));
#else
ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
size, DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT));
#endif
if (_GL_UNLIKELY (!ok))
DYNARRAY_NAME (mark_failed) (list);
return ok;
}
else
{
/* The list has shrunk in size. Free the removed elements. */
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array + size,
list->u.dynarray_header.used - size);
list->u.dynarray_header.used = size;
return true;
}
}
/* Remove the last element of LIST if it is present. */
_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
static void
DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
{
/* used > 0 implies that the array is the non-failed state. */
if (list->u.dynarray_header.used > 0)
{
size_t new_length = list->u.dynarray_header.used - 1;
#ifdef DYNARRAY_ELEMENT_FREE
DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]);
#endif
list->u.dynarray_header.used = new_length;
}
}
/* Remove all elements from the list. The elements are freed, but the
list itself is not. */
_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NONNULL ((1))
static void
DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
{
/* free__elements__ does nothing if the list is in the failed
state. */
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
list->u.dynarray_header.used = 0;
}
#ifdef DYNARRAY_FINAL_TYPE
/* Transfer the dynamic array to a permanent location at *RESULT.
Returns true on success on false on allocation failure. In either
case, *LIST is re-initialized and can be reused. A NULL pointer is
stored in *RESULT if LIST refers to an empty list. On success, the
pointer in *RESULT is heap-allocated and must be deallocated using
free. */
_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
_GL_ATTRIBUTE_NONNULL ((1, 2))
static bool
DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
DYNARRAY_FINAL_TYPE *result)
{
struct dynarray_finalize_result res;
if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT), &res))
{
/* On success, the result owns all the data. */
DYNARRAY_NAME (init) (list);
*result = (DYNARRAY_FINAL_TYPE) { res.array, res.length };
return true;
}
else
{
/* On error, we need to free all data. */
DYNARRAY_FREE (list);
errno = ENOMEM;
return false;
}
}
#else /* !DYNARRAY_FINAL_TYPE */
/* Transfer the dynamic array to a heap-allocated array and return a
pointer to it. The pointer is NULL if memory allocation fails, or
if the array is empty, so this function should be used only for
arrays which are known not be empty (usually because they always
have a sentinel at the end). If LENGTHP is not NULL, the array
length is written to *LENGTHP. *LIST is re-initialized and can be
reused. */
_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_NODISCARD
_GL_ATTRIBUTE_NONNULL ((1))
static DYNARRAY_ELEMENT *
DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
{
struct dynarray_finalize_result res;
if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT), &res))
{
/* On success, the result owns all the data. */
DYNARRAY_NAME (init) (list);
if (lengthp != NULL)
*lengthp = res.length;
return res.array;
}
else
{
/* On error, we need to free all data. */
DYNARRAY_FREE (list);
errno = ENOMEM;
return NULL;
}
}
#endif /* !DYNARRAY_FINAL_TYPE */
/* Undo macro definitions. */
#undef DYNARRAY_CONCAT0
#undef DYNARRAY_CONCAT1
#undef DYNARRAY_NAME
#undef DYNARRAY_SCRATCH
#undef DYNARRAY_HAVE_SCRATCH
#undef DYNARRAY_STRUCT
#undef DYNARRAY_ELEMENT
#undef DYNARRAY_PREFIX
#undef DYNARRAY_ELEMENT_FREE
#undef DYNARRAY_ELEMENT_INIT
#undef DYNARRAY_INITIAL_SIZE
#undef DYNARRAY_FINAL_TYPE

View File

@@ -1,173 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Type-safe arrays which grow dynamically. Shared definitions.
Copyright (C) 2017-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* To use the dynarray facility, you need to include
<malloc/dynarray-skeleton.c> and define the parameter macros
documented in that file.
A minimal example which provides a growing list of integers can be
defined like this:
struct int_array
{
// Pointer to result array followed by its length,
// as required by DYNARRAY_FINAL_TYPE.
int *array;
size_t length;
};
#define DYNARRAY_STRUCT dynarray_int
#define DYNARRAY_ELEMENT int
#define DYNARRAY_PREFIX dynarray_int_
#define DYNARRAY_FINAL_TYPE struct int_array
#include <malloc/dynarray-skeleton.c>
To create a three-element array with elements 1, 2, 3, use this
code:
struct dynarray_int dyn;
dynarray_int_init (&dyn);
for (int i = 1; i <= 3; ++i)
{
int *place = dynarray_int_emplace (&dyn);
assert (place != NULL);
*place = i;
}
struct int_array result;
bool ok = dynarray_int_finalize (&dyn, &result);
assert (ok);
assert (result.length == 3);
assert (result.array[0] == 1);
assert (result.array[1] == 2);
assert (result.array[2] == 3);
free (result.array);
If the elements contain resources which must be freed, define
DYNARRAY_ELEMENT_FREE appropriately, like this:
struct str_array
{
char **array;
size_t length;
};
#define DYNARRAY_STRUCT dynarray_str
#define DYNARRAY_ELEMENT char *
#define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
#define DYNARRAY_PREFIX dynarray_str_
#define DYNARRAY_FINAL_TYPE struct str_array
#include <malloc/dynarray-skeleton.c>
Compared to scratch buffers, dynamic arrays have the following
features:
- They have an element type, and are not just an untyped buffer of
bytes.
- When growing, previously stored elements are preserved. (It is
expected that scratch_buffer_grow_preserve and
scratch_buffer_set_array_size eventually go away because all
current users are moved to dynamic arrays.)
- Scratch buffers have a more aggressive growth policy because
growing them typically means a retry of an operation (across an
NSS service module boundary), which is expensive.
- For the same reason, scratch buffers have a much larger initial
stack allocation. */
#ifndef _DYNARRAY_H
#define _DYNARRAY_H
#include <stddef.h>
#include <string.h>
struct dynarray_header
{
size_t used;
size_t allocated;
void *array;
};
/* Marker used in the allocated member to indicate that an error was
encountered. */
static inline size_t
__dynarray_error_marker (void)
{
return -1;
}
/* Internal function. See the has_failed function in
dynarray-skeleton.c. */
static inline bool
__dynarray_error (struct dynarray_header *list)
{
return list->allocated == __dynarray_error_marker ();
}
/* Internal function. Enlarge the dynamically allocated area of the
array to make room for one more element. SCRATCH is a pointer to
the scratch area (which is not heap-allocated and must not be
freed). ELEMENT_SIZE is the size, in bytes, of one element.
Return false on failure, true on success. */
bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
void *scratch, size_t element_size);
/* Internal function. Enlarge the dynamically allocated area of the
array to make room for at least SIZE elements (which must be larger
than the existing used part of the dynamic array). SCRATCH is a
pointer to the scratch area (which is not heap-allocated and must
not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
Return false on failure, true on success. */
bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
void *scratch, size_t element_size);
/* Internal function. Like __libc_dynarray_resize, but clear the new
part of the dynamic array. */
bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
void *scratch, size_t element_size);
/* Internal type. */
struct dynarray_finalize_result
{
void *array;
size_t length;
};
/* Internal function. Copy the dynamically-allocated area to an
explicitly-sized heap allocation. SCRATCH is a pointer to the
embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
element type. On success, true is returned, and pointer and length
are written to *RESULT. On failure, false is returned. The caller
has to take care of some of the memory management; this function is
expected to be called from dynarray-skeleton.c. */
bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
size_t element_size,
struct dynarray_finalize_result *result);
/* Internal function. Terminate the process after an index error.
SIZE is the number of elements of the dynamic array. INDEX is the
lookup index which triggered the failure. */
_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
#ifndef _ISOMAC
#endif
#endif /* _DYNARRAY_H */

View File

@@ -1,133 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Variable-sized buffer with on-stack default allocation.
Copyright (C) 2015-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _SCRATCH_BUFFER_H
#define _SCRATCH_BUFFER_H
/* Scratch buffers with a default stack allocation and fallback to
heap allocation. It is expected that this function is used in this
way:
struct scratch_buffer tmpbuf;
scratch_buffer_init (&tmpbuf);
while (!function_that_uses_buffer (tmpbuf.data, tmpbuf.length))
if (!scratch_buffer_grow (&tmpbuf))
return -1;
scratch_buffer_free (&tmpbuf);
return 0;
The allocation functions (scratch_buffer_grow,
scratch_buffer_grow_preserve, scratch_buffer_set_array_size) make
sure that the heap allocation, if any, is freed, so that the code
above does not have a memory leak. The buffer still remains in a
state that can be deallocated using scratch_buffer_free, so a loop
like this is valid as well:
struct scratch_buffer tmpbuf;
scratch_buffer_init (&tmpbuf);
while (!function_that_uses_buffer (tmpbuf.data, tmpbuf.length))
if (!scratch_buffer_grow (&tmpbuf))
break;
scratch_buffer_free (&tmpbuf);
scratch_buffer_grow and scratch_buffer_grow_preserve are guaranteed
to grow the buffer by at least 512 bytes. This means that when
using the scratch buffer as a backing store for a non-character
array whose element size, in bytes, is 512 or smaller, the scratch
buffer only has to grow once to make room for at least one more
element.
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
/* Scratch buffer. Must be initialized with scratch_buffer_init
before its use. */
struct scratch_buffer {
void *data; /* Pointer to the beginning of the scratch area. */
size_t length; /* Allocated space at the data pointer, in bytes. */
union { max_align_t __align; char __c[1024]; } __space;
};
/* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space
and BUFFER->length reflects the available space. */
static inline void
scratch_buffer_init (struct scratch_buffer *buffer)
{
buffer->data = buffer->__space.__c;
buffer->length = sizeof (buffer->__space);
}
/* Deallocates *BUFFER (if it was heap-allocated). */
static inline void
scratch_buffer_free (struct scratch_buffer *buffer)
{
if (buffer->data != buffer->__space.__c)
free (buffer->data);
}
/* Grow *BUFFER by some arbitrary amount. The buffer contents is NOT
preserved. Return true on success, false on allocation failure (in
which case the old buffer is freed). On success, the new buffer is
larger than the previous size. On failure, *BUFFER is deallocated,
but remains in a free-able state, and errno is set. */
bool __libc_scratch_buffer_grow (struct scratch_buffer *buffer);
/* Alias for __libc_scratch_buffer_grow. */
static inline _GL_ATTRIBUTE_ALWAYS_INLINE bool
scratch_buffer_grow (struct scratch_buffer *buffer)
{
return _GL_LIKELY (__libc_scratch_buffer_grow (buffer));
}
/* Like __libc_scratch_buffer_grow, but preserve the old buffer
contents on success, as a prefix of the new buffer. */
bool __libc_scratch_buffer_grow_preserve (struct scratch_buffer *buffer);
/* Alias for __libc_scratch_buffer_grow_preserve. */
static inline _GL_ATTRIBUTE_ALWAYS_INLINE bool
scratch_buffer_grow_preserve (struct scratch_buffer *buffer)
{
return _GL_LIKELY (__libc_scratch_buffer_grow_preserve (buffer));
}
/* Grow *BUFFER so that it can store at least NELEM elements of SIZE
bytes. The buffer contents are NOT preserved. Both NELEM and SIZE
can be zero. Return true on success, false on allocation failure
(in which case the old buffer is freed, but *BUFFER remains in a
free-able state, and errno is set). It is unspecified whether this
function can reduce the array size. */
bool __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
size_t nelem, size_t size);
/* Alias for __libc_scratch_set_array_size. */
static inline _GL_ATTRIBUTE_ALWAYS_INLINE bool
scratch_buffer_set_array_size (struct scratch_buffer *buffer,
size_t nelem, size_t size)
{
return _GL_LIKELY (__libc_scratch_buffer_set_array_size
(buffer, nelem, size));
}
#endif /* _SCRATCH_BUFFER_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,622 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A GNU-like <sched.h>.
Copyright (C) 2008-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_SCHED_H
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
/* This file uses #include_next of a system file that defines time_t.
For the 'year2038' module to work right, <config.h> needs to have been
included before. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
/* The include_next requires a split double-inclusion guard. */
#if 1
# if 0
# include <sys/cdefs.h>
# endif
# include_next <sched.h>
#endif
#ifndef _GL_SCHED_H
#define _GL_SCHED_H
/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
/* Get pid_t.
This is needed on glibc 2.11 (see
glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=13198>)
and Mac OS X 10.5. */
#include <sys/types.h>
#ifdef __KLIBC__
/* On OS/2 kLIBC, struct sched_param is in spawn.h. */
# include <spawn.h>
#endif
#ifdef __VMS
/* On OpenVMS, struct sched_param is in <pthread.h>. */
# include <pthread.h>
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* C++ compatible function declaration macros.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
/* Begin/end the GNULIB_NAMESPACE namespace. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif
/* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some
platforms, but is declared and works fine on the platforms on which
it exists:
#if @GNULIB_FOO@
# if !@HAVE_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on all platforms,
but is broken/insufficient and needs to be replaced on some platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on some platforms
but is broken/insufficient and needs to be replaced on some of them and
is additionally either missing or undeclared on some other platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
# if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
*/
/* _GL_EXTERN_C declaration;
performs the declaration with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C extern "C"
#else
# define _GL_EXTERN_C extern
#endif
/* _GL_EXTERN_C_FUNC declaration;
performs the declaration of a function with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C_FUNC extern "C"
#else
/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
are not allowed between 'extern' and the return type (see gnulib-common.m4).
*/
# define _GL_EXTERN_C_FUNC
#endif
/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
declares a replacement function, named rpl_func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
_GL_ARG_NONNULL ((1)));
Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
because
[[...]] extern "C" <declaration>;
is invalid syntax in C++.)
*/
#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
declares the system function, named func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
*/
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
Wrapping rpl_func in an object with an inline conversion operator
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::rpl_func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
is to be used when func is a Microsoft deprecated alias, on native Windows.
It declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to _func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
*/
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
except that the C function rpl_func may have a slightly different
declaration. A cast is used to silence the "invalid conversion" error
that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::rpl_func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
Wrapping func in an object with an inline conversion operator
avoids a reference to func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function is picked among a set of overloaded functions,
namely the one with rettype2 and parameters2. Two consecutive casts
are used to silence the "cannot find a match" and "invalid conversion"
errors that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
/* The outer cast must be a reinterpret_cast.
The inner cast: When the function is defined as a set of overloaded
functions, it works as a static_cast<>, choosing the designated variant.
When the function is defined as a single variant, it works as a
reinterpret_cast<>. The parenthesized cast syntax works both ways. */
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN (func);
causes a warning to be emitted when ::func is used but not when
GNULIB_NAMESPACE::func is used. func must be defined without overloaded
variants. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN(func) \
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN_2(func,namespace) \
extern __typeof__ (func) func
# else
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN(func) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
causes a warning to be emitted when the given overloaded variant of ::func
is used but not when GNULIB_NAMESPACE::func is used. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# else
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
#endif /* _GL_CXXDEFS_H */
/* The definition of _GL_WARN_ON_USE is copied here. */
/* A C macro for emitting warnings if a function is used.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
for FUNCTION which will then trigger a compiler warning containing
the text of "literal string" anywhere that function is called, if
supported by the compiler. If the compiler does not support this
feature, the macro expands to an unused extern declaration.
_GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
attribute used in _GL_WARN_ON_USE. If the compiler does not support
this feature, it expands to empty.
These macros are useful for marking a function as a potential
portability trap, with the intent that "literal string" include
instructions on the replacement function that should be used
instead.
_GL_WARN_ON_USE is for functions with 'extern' linkage.
_GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
linkage.
_GL_WARN_ON_USE should not be used more than once for a given function
in a given compilation unit (because this may generate a warning even
if the function is never called).
However, one of the reasons that a function is a portability trap is
if it has the wrong signature. Declaring FUNCTION with a different
signature in C is a compilation error, so this macro must use the
same type as any existing declaration so that programs that avoid
the problematic FUNCTION do not fail to compile merely because they
included a header that poisoned the function. But this implies that
_GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
have a declaration. Use of this macro implies that there must not
be any other macro hiding the declaration of FUNCTION; but
undefining FUNCTION first is part of the poisoning process anyway
(although for symbols that are provided only via a macro, the result
is a compilation error rather than a warning containing
"literal string"). Also note that in C++, it is only safe to use if
FUNCTION has no overloads.
For an example, it is possible to poison 'getline' by:
- adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
[getline]) in configure.ac, which potentially defines
HAVE_RAW_DECL_GETLINE
- adding this code to a header that wraps the system <stdio.h>:
#undef getline
#if HAVE_RAW_DECL_GETLINE
_GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
"not universally present; use the gnulib module getline");
#endif
It is not possible to directly poison global variables. But it is
possible to write a wrapper accessor function, and poison that
(less common usage, like &environ, will cause a compilation error
rather than issue the nice warning, but the end result of informing
the developer about their portability problem is still achieved):
#if HAVE_RAW_DECL_ENVIRON
static char ***
rpl_environ (void) { return &environ; }
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
# undef environ
# define environ (*rpl_environ ())
#endif
or better (avoiding contradictory use of 'static' and 'extern'):
#if HAVE_RAW_DECL_ENVIRON
static char ***
_GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
rpl_environ (void) { return &environ; }
# undef environ
# define environ (*rpl_environ ())
#endif
*/
#ifndef _GL_WARN_ON_USE
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__warning__ (message)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# endif
#endif
/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
function is declared with the given prototype, consisting of return type,
parameters, and attributes.
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
not work in this case. */
#ifndef _GL_WARN_ON_USE_CXX
# if !defined __cplusplus
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_ON_USE (function, msg)
# else
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_clang function parameters_and_attributes \
__attribute__ ((__diagnose_if__ (1, msg, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif
# endif
#endif
/* _GL_WARN_EXTERN_C declaration;
performs the declaration with C linkage. */
#ifndef _GL_WARN_EXTERN_C
# if defined __cplusplus
# define _GL_WARN_EXTERN_C extern "C"
# else
# define _GL_WARN_EXTERN_C extern
# endif
#endif
#if !1
# if !GNULIB_defined_struct_sched_param
struct sched_param
{
int sched_priority;
};
# define GNULIB_defined_struct_sched_param 1
# endif
#endif
#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER)
# define SCHED_FIFO 1
# define SCHED_RR 2
# define SCHED_OTHER 0
#endif
#if IN_PARTED_GNULIB_TESTS
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef sched_yield
# define sched_yield rpl_sched_yield
# endif
_GL_FUNCDECL_RPL (sched_yield, int, (void), );
_GL_CXXALIAS_RPL (sched_yield, int, (void));
# else
# if !1
_GL_FUNCDECL_SYS (sched_yield, int, (void), );
# endif
_GL_CXXALIAS_SYS (sched_yield, int, (void));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (sched_yield);
# endif
#elif defined GNULIB_POSIXCHECK
# undef sched_yield
# if HAVE_RAW_DECL_SCHED_YIELD
_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - "
"use gnulib module sched_yield for portability");
# endif
#endif
#endif /* _GL_SCHED_H */
#endif /* _GL_SCHED_H */

View File

@@ -1,230 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
Copyright (C) 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Eric Blake. */
/*
* POSIX 2008 and ISO C 23 <stddef.h> for platforms that have issues.
* <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
*/
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
#if (defined __need_wchar_t || defined __need_size_t \
|| defined __need_ptrdiff_t || defined __need_NULL \
|| defined __need_wint_t) \
/* Avoid warning triggered by "gcc -std=gnu23 -Wsystem-headers" \
in Fedora 40 with gcc 14.0.1. \
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870>. */ \
&& !0
/* Special invocation convention inside gcc header files. In
particular, <stddef.h> in some ancient versions of GCC blindly
redefined NULL when __need_wint_t was defined, even though wint_t
is not normally provided by <stddef.h>.
(FIXME: It's not clear what GCC versions those were - perhaps so
ancient that we can stop worrying about this?)
Although glibc 2.26 (2017) and later do not use __need_wint_t,
for portability to macOS, Cygwin, Haiku, and older Glibc + GCC,
remember if special invocation has ever been used to obtain wint_t,
in which case we need to clean up NULL yet again. */
# if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T)
# ifdef __need_wint_t
# define _GL_STDDEF_WINT_T
# endif
# include_next <stddef.h>
/* On TinyCC, make sure that the macros that indicate the special invocation
convention get undefined. */
# undef __need_wchar_t
# undef __need_size_t
# undef __need_ptrdiff_t
# undef __need_NULL
# undef __need_wint_t
# endif
#else
/* For 0. */
# undef __need_wchar_t
# undef __need_size_t
# undef __need_ptrdiff_t
# undef __need_NULL
# undef __need_wint_t
/* Normal invocation convention. */
# ifndef _GL_STDDEF_H
/* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
type with alignment 4, but 'long' has alignment 8. */
# if defined _AIX && defined __LP64__ && !1
# if !GNULIB_defined_max_align_t
# ifdef _MAX_ALIGN_T
/* /usr/include/stddef.h has already defined max_align_t. Override it. */
typedef long rpl_max_align_t;
# define max_align_t rpl_max_align_t
# else
/* Prevent /usr/include/stddef.h from defining max_align_t. */
typedef long max_align_t;
# define _MAX_ALIGN_T
# endif
# define __CLANG_MAX_ALIGN_T_DEFINED
# define GNULIB_defined_max_align_t 1
# endif
# endif
# if !defined _GCC_NULLPTR_T && !1
/* Suppress unwanted nullptr_t typedef. See
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114869>. */
# define _GCC_NULLPTR_T
# endif
/* The include_next requires a split double-inclusion guard. */
# include_next <stddef.h>
/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
# if (0 \
&& (!defined _GL_STDDEF_H || defined _GL_STDDEF_WINT_T))
# undef NULL
# ifdef __cplusplus
/* ISO C++ says that the macro NULL must expand to an integer constant
expression, hence '((void *) 0)' is not allowed in C++. */
# if __GNUG__ >= 3
/* GNU C++ has a __null macro that behaves like an integer ('int' or
'long') but has the same size as a pointer. Use that, to avoid
warnings. */
# define NULL __null
# else
# define NULL 0L
# endif
# else
# define NULL ((void *) 0)
# endif
# endif
# ifndef _GL_STDDEF_H
# define _GL_STDDEF_H
/* This file uses _Noreturn, _GL_ATTRIBUTE_NOTHROW. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
*/
#ifndef _GL_ATTRIBUTE_NOTHROW
# if defined __cplusplus
# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
# if __cplusplus >= 201103L
# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
# else
# define _GL_ATTRIBUTE_NOTHROW throw ()
# endif
# else
# define _GL_ATTRIBUTE_NOTHROW
# endif
# else
# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
# else
# define _GL_ATTRIBUTE_NOTHROW
# endif
# endif
#endif
/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is
a hack in case the configure-time test was done with g++ even though
we are currently compiling with gcc.
On MSVC, max_align_t is defined only in C++ mode, after <cstddef> was
included. Its definition is good since it has an alignment of 8 (on x86
and x86_64).
Similarly on OS/2 kLIBC. */
#if (defined _MSC_VER || (defined __KLIBC__ && !defined __LIBCN__)) \
&& defined __cplusplus
# include <cstddef>
#else
# if ! (1 || (defined _GCC_MAX_ALIGN_T && !defined __clang__))
# if !GNULIB_defined_max_align_t
/* On the x86, the maximum storage alignment of double, long, etc. is 4,
but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
and the C11 standard allows this. Work around this problem by
using __alignof__ (which returns 8 for double) rather than _Alignof
(which returns 4), and align each union member accordingly. */
# if defined __GNUC__ || (__clang_major__ >= 4)
# define _GL_STDDEF_ALIGNAS(type) \
__attribute__ ((__aligned__ (__alignof__ (type))))
# else
# define _GL_STDDEF_ALIGNAS(type) /* */
# endif
typedef union
{
char *__p _GL_STDDEF_ALIGNAS (char *);
double __d _GL_STDDEF_ALIGNAS (double);
long double __ld _GL_STDDEF_ALIGNAS (long double);
long int __i _GL_STDDEF_ALIGNAS (long int);
} rpl_max_align_t;
# define max_align_t rpl_max_align_t
# define __CLANG_MAX_ALIGN_T_DEFINED
# define GNULIB_defined_max_align_t 1
# endif
# endif
#endif
/* ISO C 23 § 7.21.1 The unreachable macro */
#ifndef unreachable
/* Code borrowed from verify.h. */
# ifndef _GL_HAS_BUILTIN_UNREACHABLE
# if defined __clang_major__ && __clang_major__ < 5
# define _GL_HAS_BUILTIN_UNREACHABLE 0
# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__
# define _GL_HAS_BUILTIN_UNREACHABLE 1
# elif defined __has_builtin
# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
# else
# define _GL_HAS_BUILTIN_UNREACHABLE 0
# endif
# endif
# if _GL_HAS_BUILTIN_UNREACHABLE
# define unreachable() __builtin_unreachable ()
# elif 1200 <= _MSC_VER
# define unreachable() __assume (0)
# else
/* Declare abort(), without including <stdlib.h>. */
extern
# if defined __cplusplus
"C"
# endif
_Noreturn
void abort (void)
# if defined __cplusplus && (__GLIBC__ >= 2)
_GL_ATTRIBUTE_NOTHROW
# endif
;
# define unreachable() abort ()
# endif
#endif
# endif /* _GL_STDDEF_H */
# endif /* _GL_STDDEF_H */
#endif /* __need_XXX */

View File

@@ -1,752 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Copyright (C) 2001-2002, 2004-2024 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
This file is part of gnulib.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/*
* ISO C 99 <stdint.h> for platforms that lack it.
* <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html>
*/
#ifndef _GL_STDINT_H
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
/* When including a system file that in turn includes <inttypes.h>,
use the system <inttypes.h>, not our substitute. This avoids
problems with (for example) VMS, whose <sys/bitypes.h> includes
<inttypes.h>. */
#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
/* On Android (Bionic libc), <sys/types.h> includes this file before
having defined 'time_t'. Therefore in this case avoid including
other system header files; just include the system's <stdint.h>.
Ideally we should test __BIONIC__ here, but it is only defined after
<sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H
# include_next <stdint.h>
#else
/* Get those types that are already defined in other system include
files, so that we can "#define int8_t signed char" below without
worrying about a later system include file containing a "typedef
signed char int8_t;" that will get messed up by our macro. Our
macros should all be consistent with the system versions, except
for the "fast" types and macros, which we recommend against using
in public interfaces due to compiler differences. */
#if 1
# if defined __sgi && ! defined __c99
/* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
with "This header file is to be used only for c99 mode compilations"
diagnostics. */
# define __STDINT_H__
# endif
/* Some pre-C++11 <stdint.h> implementations need this. */
# ifdef __cplusplus
# ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS 1
# endif
# ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS 1
# endif
# endif
/* Other systems may have an incomplete or buggy <stdint.h>.
Include it before <inttypes.h>, since any "#include <stdint.h>"
in <inttypes.h> would reinclude us, skipping our contents because
_GL_STDINT_H is defined.
The include_next requires a split double-inclusion guard. */
# include_next <stdint.h>
#endif
#if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
#define _GL_STDINT_H
/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
LONG_MIN, LONG_MAX, ULONG_MAX, CHAR_BIT, _GL_INTEGER_WIDTH. */
#include <limits.h>
/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
wint_t. */
#if 0
# undef WINT_MIN
# undef WINT_MAX
# define WINT_MIN 0x0U
# define WINT_MAX 0xffffffffU
#endif
#if ! 0
/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
AIX 5.2 <sys/types.h> isn't needed and causes troubles.
Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
relies on the system <stdint.h> definitions, so include
<sys/types.h> after <stdint.h>. */
# if 1 && ! defined _AIX
# include <sys/types.h>
# endif
# if 1
/* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
<inttypes.h> also defines intptr_t and uintptr_t. */
# include <inttypes.h>
# elif 0
/* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
# include <sys/inttypes.h>
# endif
# if 0 && ! defined __BIT_TYPES_DEFINED__
/* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
included by <sys/types.h>. */
# include <sys/bitypes.h>
# endif
# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
/* Minimum and maximum values for an integer type under the usual assumption.
Return an unspecified value if BITS == 0, adding a check to pacify
picky compilers. */
/* These are separate macros, because if you try to merge these macros into
a single one, HP-UX cc rejects the resulting expression in constant
expressions. */
# define _STDINT_UNSIGNED_MIN(bits, zero) \
(zero)
# define _STDINT_SIGNED_MIN(bits, zero) \
(~ _STDINT_MAX (1, bits, zero))
# define _STDINT_MAX(signed, bits, zero) \
(((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
#if !GNULIB_defined_stdint_types
/* 7.18.1.1. Exact-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. */
# undef int8_t
# undef uint8_t
typedef signed char gl_int8_t;
typedef unsigned char gl_uint8_t;
# define int8_t gl_int8_t
# define uint8_t gl_uint8_t
# undef int16_t
# undef uint16_t
typedef short int gl_int16_t;
typedef unsigned short int gl_uint16_t;
# define int16_t gl_int16_t
# define uint16_t gl_uint16_t
# undef int32_t
# undef uint32_t
typedef int gl_int32_t;
typedef unsigned int gl_uint32_t;
# define int32_t gl_int32_t
# define uint32_t gl_uint32_t
/* If the system defines INT64_MAX, assume int64_t works. That way,
if the underlying platform defines int64_t to be a 64-bit long long
int, the code below won't mistakenly define it to be a 64-bit long
int, which would mess up C++ name mangling. We must use #ifdef
rather than #if, to avoid an error with HP-UX 10.20 cc. */
# ifdef INT64_MAX
# define GL_INT64_T
# else
/* Do not undefine int64_t if gnulib is not being used with 64-bit
types, since otherwise it breaks platforms like Tandem/NSK. */
# if LONG_MAX >> 31 >> 31 == 1
# undef int64_t
typedef long int gl_int64_t;
# define int64_t gl_int64_t
# define GL_INT64_T
# elif defined _MSC_VER
# undef int64_t
typedef __int64 gl_int64_t;
# define int64_t gl_int64_t
# define GL_INT64_T
# else
/* Verify that 'long long' has exactly 64 bits. */
typedef _gl_verify_int64_bits[
_STDINT_MAX (1, sizeof (long long) * CHAR_BIT, 0ll) >> 31 >> 31 == 1
? 1 : -1];
# undef int64_t
typedef long long int gl_int64_t;
# define int64_t gl_int64_t
# define GL_INT64_T
# endif
# endif
# ifdef UINT64_MAX
# define GL_UINT64_T
# else
# if ULONG_MAX >> 31 >> 31 >> 1 == 1
# undef uint64_t
typedef unsigned long int gl_uint64_t;
# define uint64_t gl_uint64_t
# define GL_UINT64_T
# elif defined _MSC_VER
# undef uint64_t
typedef unsigned __int64 gl_uint64_t;
# define uint64_t gl_uint64_t
# define GL_UINT64_T
# else
/* Verify that 'unsigned long long' has exactly 64 bits. */
typedef _gl_verify_uint64_bits[
_STDINT_MAX (0, sizeof (unsigned long long) * CHAR_BIT, 0ull)
>> 31 >> 31 >> 1 == 1
? 1 : -1];
# undef uint64_t
typedef unsigned long long int gl_uint64_t;
# define uint64_t gl_uint64_t
# define GL_UINT64_T
# endif
# endif
/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
# define _UINT8_T
# define _UINT32_T
# define _UINT64_T
/* 7.18.1.2. Minimum-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
are the same as the corresponding N_t types. */
# undef int_least8_t
# undef uint_least8_t
# undef int_least16_t
# undef uint_least16_t
# undef int_least32_t
# undef uint_least32_t
# undef int_least64_t
# undef uint_least64_t
# define int_least8_t int8_t
# define uint_least8_t uint8_t
# define int_least16_t int16_t
# define uint_least16_t uint16_t
# define int_least32_t int32_t
# define uint_least32_t uint32_t
# ifdef GL_INT64_T
# define int_least64_t int64_t
# endif
# ifdef GL_UINT64_T
# define uint_least64_t uint64_t
# endif
/* 7.18.1.3. Fastest minimum-width integer types */
/* Note: Other <stdint.h> substitutes may define these types differently.
It is not recommended to use these types in public header files. */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
are taken from the same list of types. The following code normally
uses types consistent with glibc, as that lessens the chance of
incompatibility with older GNU hosts. */
# undef int_fast8_t
# undef uint_fast8_t
# undef int_fast16_t
# undef uint_fast16_t
# undef int_fast32_t
# undef uint_fast32_t
# undef int_fast64_t
# undef uint_fast64_t
typedef signed char gl_int_fast8_t;
typedef unsigned char gl_uint_fast8_t;
# ifdef __sun
/* Define types compatible with SunOS 5.10, so that code compiled under
earlier SunOS versions works with code compiled under SunOS 5.10. */
typedef int gl_int_fast32_t;
typedef unsigned int gl_uint_fast32_t;
# else
typedef long int gl_int_fast32_t;
typedef unsigned long int gl_uint_fast32_t;
# endif
typedef gl_int_fast32_t gl_int_fast16_t;
typedef gl_uint_fast32_t gl_uint_fast16_t;
# define int_fast8_t gl_int_fast8_t
# define uint_fast8_t gl_uint_fast8_t
# define int_fast16_t gl_int_fast16_t
# define uint_fast16_t gl_uint_fast16_t
# define int_fast32_t gl_int_fast32_t
# define uint_fast32_t gl_uint_fast32_t
# ifdef GL_INT64_T
# define int_fast64_t int64_t
# endif
# ifdef GL_UINT64_T
# define uint_fast64_t uint64_t
# endif
/* 7.18.1.4. Integer types capable of holding object pointers */
/* kLIBC's <stdint.h> defines _INTPTR_T_DECLARED and needs its own
definitions of intptr_t and uintptr_t (which use int and unsigned)
to avoid clashes with declarations of system functions like sbrk.
Similarly, MinGW WSL-5.4.1 <stdint.h> needs its own intptr_t and
uintptr_t to avoid conflicting declarations of system functions like
_findclose in <io.h>. */
# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
|| (defined __INTPTR_WIDTH__ \
&& __INTPTR_WIDTH__ != (defined _WIN64 ? LLONG_WIDTH : LONG_WIDTH)) \
|| defined __MINGW32__)
# undef intptr_t
# undef uintptr_t
# ifdef _WIN64
typedef long long int gl_intptr_t;
typedef unsigned long long int gl_uintptr_t;
# else
typedef long int gl_intptr_t;
typedef unsigned long int gl_uintptr_t;
# endif
# define intptr_t gl_intptr_t
# define uintptr_t gl_uintptr_t
# endif
/* 7.18.1.5. Greatest-width integer types */
/* Note: These types are compiler dependent. It may be unwise to use them in
public header files. */
/* If the system defines INTMAX_MAX, assume that intmax_t works, and
similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
assuming one type where another is used by the system. */
# ifndef INTMAX_MAX
# undef INTMAX_C
# undef intmax_t
# if LONG_MAX >> 30 == 1
typedef long long int gl_intmax_t;
# define intmax_t gl_intmax_t
# elif defined GL_INT64_T
# define intmax_t int64_t
# else
typedef long int gl_intmax_t;
# define intmax_t gl_intmax_t
# endif
# endif
# ifndef UINTMAX_MAX
# undef UINTMAX_C
# undef uintmax_t
# if ULONG_MAX >> 31 == 1
typedef unsigned long long int gl_uintmax_t;
# define uintmax_t gl_uintmax_t
# elif defined GL_UINT64_T
# define uintmax_t uint64_t
# else
typedef unsigned long int gl_uintmax_t;
# define uintmax_t gl_uintmax_t
# endif
# endif
/* Verify that intmax_t and uintmax_t have the same size. Too much code
breaks if this is not the case. If this check fails, the reason is likely
to be found in the autoconf macros. */
typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
? 1 : -1];
# define GNULIB_defined_stdint_types 1
# endif /* !GNULIB_defined_stdint_types */
/* 7.18.2. Limits of specified-width integer types */
/* 7.18.2.1. Limits of exact-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. */
# undef INT8_MIN
# undef INT8_MAX
# undef UINT8_MAX
# define INT8_MIN (~ INT8_MAX)
# define INT8_MAX 127
# define UINT8_MAX 255
# undef INT16_MIN
# undef INT16_MAX
# undef UINT16_MAX
# define INT16_MIN (~ INT16_MAX)
# define INT16_MAX 32767
# define UINT16_MAX 65535
# undef INT32_MIN
# undef INT32_MAX
# undef UINT32_MAX
# define INT32_MIN (~ INT32_MAX)
# define INT32_MAX 2147483647
# define UINT32_MAX 4294967295U
# if defined GL_INT64_T && ! defined INT64_MAX
/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
evaluates the latter incorrectly in preprocessor expressions. */
# define INT64_MIN (- INTMAX_C (1) << 63)
# define INT64_MAX INTMAX_C (9223372036854775807)
# endif
# if defined GL_UINT64_T && ! defined UINT64_MAX
# define UINT64_MAX UINTMAX_C (18446744073709551615)
# endif
/* 7.18.2.2. Limits of minimum-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
are the same as the corresponding N_t types. */
# undef INT_LEAST8_MIN
# undef INT_LEAST8_MAX
# undef UINT_LEAST8_MAX
# define INT_LEAST8_MIN INT8_MIN
# define INT_LEAST8_MAX INT8_MAX
# define UINT_LEAST8_MAX UINT8_MAX
# undef INT_LEAST16_MIN
# undef INT_LEAST16_MAX
# undef UINT_LEAST16_MAX
# define INT_LEAST16_MIN INT16_MIN
# define INT_LEAST16_MAX INT16_MAX
# define UINT_LEAST16_MAX UINT16_MAX
# undef INT_LEAST32_MIN
# undef INT_LEAST32_MAX
# undef UINT_LEAST32_MAX
# define INT_LEAST32_MIN INT32_MIN
# define INT_LEAST32_MAX INT32_MAX
# define UINT_LEAST32_MAX UINT32_MAX
# undef INT_LEAST64_MIN
# undef INT_LEAST64_MAX
# ifdef GL_INT64_T
# define INT_LEAST64_MIN INT64_MIN
# define INT_LEAST64_MAX INT64_MAX
# endif
# undef UINT_LEAST64_MAX
# ifdef GL_UINT64_T
# define UINT_LEAST64_MAX UINT64_MAX
# endif
/* 7.18.2.3. Limits of fastest minimum-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
are taken from the same list of types. */
# undef INT_FAST8_MIN
# undef INT_FAST8_MAX
# undef UINT_FAST8_MAX
# define INT_FAST8_MIN SCHAR_MIN
# define INT_FAST8_MAX SCHAR_MAX
# define UINT_FAST8_MAX UCHAR_MAX
# undef INT_FAST16_MIN
# undef INT_FAST16_MAX
# undef UINT_FAST16_MAX
# define INT_FAST16_MIN INT_FAST32_MIN
# define INT_FAST16_MAX INT_FAST32_MAX
# define UINT_FAST16_MAX UINT_FAST32_MAX
# undef INT_FAST32_MIN
# undef INT_FAST32_MAX
# undef UINT_FAST32_MAX
# ifdef __sun
# define INT_FAST32_MIN INT_MIN
# define INT_FAST32_MAX INT_MAX
# define UINT_FAST32_MAX UINT_MAX
# else
# define INT_FAST32_MIN LONG_MIN
# define INT_FAST32_MAX LONG_MAX
# define UINT_FAST32_MAX ULONG_MAX
# endif
# undef INT_FAST64_MIN
# undef INT_FAST64_MAX
# ifdef GL_INT64_T
# define INT_FAST64_MIN INT64_MIN
# define INT_FAST64_MAX INT64_MAX
# endif
# undef UINT_FAST64_MAX
# ifdef GL_UINT64_T
# define UINT_FAST64_MAX UINT64_MAX
# endif
/* 7.18.2.4. Limits of integer types capable of holding object pointers */
# undef INTPTR_MIN
# undef INTPTR_MAX
# undef UINTPTR_MAX
# ifdef _WIN64
# define INTPTR_MIN LLONG_MIN
# define INTPTR_MAX LLONG_MAX
# define UINTPTR_MAX ULLONG_MAX
# else
# define INTPTR_MIN LONG_MIN
# define INTPTR_MAX LONG_MAX
# define UINTPTR_MAX ULONG_MAX
# endif
/* 7.18.2.5. Limits of greatest-width integer types */
# ifndef INTMAX_MAX
# undef INTMAX_MIN
# ifdef INT64_MAX
# define INTMAX_MIN INT64_MIN
# define INTMAX_MAX INT64_MAX
# else
# define INTMAX_MIN INT32_MIN
# define INTMAX_MAX INT32_MAX
# endif
# endif
# ifndef UINTMAX_MAX
# ifdef UINT64_MAX
# define UINTMAX_MAX UINT64_MAX
# else
# define UINTMAX_MAX UINT32_MAX
# endif
# endif
/* 7.18.3. Limits of other integer types */
/* ptrdiff_t limits */
# undef PTRDIFF_MIN
# undef PTRDIFF_MAX
# if 0
# ifdef _LP64
# define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l)
# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
# else
# define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0)
# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
# endif
# else
# define PTRDIFF_MIN \
_STDINT_SIGNED_MIN (64, 0l)
# define PTRDIFF_MAX \
_STDINT_MAX (1, 64, 0l)
# endif
/* sig_atomic_t limits */
# undef SIG_ATOMIC_MIN
# undef SIG_ATOMIC_MAX
# if 1
# define SIG_ATOMIC_MIN \
_STDINT_SIGNED_MIN (32, 0)
# else
# define SIG_ATOMIC_MIN \
_STDINT_UNSIGNED_MIN (32, 0)
# endif
# define SIG_ATOMIC_MAX \
_STDINT_MAX (1, 32, \
0)
/* size_t limit */
# undef SIZE_MAX
# if 0
# ifdef _LP64
# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
# else
# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
# endif
# else
# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
# endif
/* wchar_t limits */
/* Get WCHAR_MIN, WCHAR_MAX.
This include is not on the top, above, because on OSF/1 4.0 we have a
sequence of nested includes
<wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
<stdint.h> and assumes its types are already defined. */
# if 1 && ! (defined WCHAR_MIN && defined WCHAR_MAX)
# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
# include <wchar.h>
# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
# endif
# undef WCHAR_MIN
# undef WCHAR_MAX
# if 0
# define WCHAR_MIN \
_STDINT_SIGNED_MIN (32, 0u)
# else
# define WCHAR_MIN \
_STDINT_UNSIGNED_MIN (32, 0u)
# endif
# define WCHAR_MAX \
_STDINT_MAX (0, 32, 0u)
/* wint_t limits */
/* If gnulib's <wchar.h> or <wctype.h> overrides wint_t, u is not
accurate, therefore use the definitions from above. */
# if !0
# undef WINT_MIN
# undef WINT_MAX
# if 0
# define WINT_MIN \
_STDINT_SIGNED_MIN (32, 0u)
# else
# define WINT_MIN \
_STDINT_UNSIGNED_MIN (32, 0u)
# endif
# define WINT_MAX \
_STDINT_MAX (0, 32, 0u)
# endif
/* 7.18.4. Macros for integer constants */
/* 7.18.4.1. Macros for minimum-width integer constants */
/* According to ISO C 99 Technical Corrigendum 1 */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
# undef INT8_C
# undef UINT8_C
# define INT8_C(x) x
# define UINT8_C(x) x
# undef INT16_C
# undef UINT16_C
# define INT16_C(x) x
# define UINT16_C(x) x
# undef INT32_C
# undef UINT32_C
# define INT32_C(x) x
# define UINT32_C(x) x ## U
# undef INT64_C
# undef UINT64_C
# if LONG_MAX >> 31 >> 31 == 1
# define INT64_C(x) x##L
# elif defined _MSC_VER
# define INT64_C(x) x##i64
# else
# define INT64_C(x) x##LL
# endif
# if ULONG_MAX >> 31 >> 31 >> 1 == 1
# define UINT64_C(x) x##UL
# elif defined _MSC_VER
# define UINT64_C(x) x##ui64
# else
# define UINT64_C(x) x##ULL
# endif
/* 7.18.4.2. Macros for greatest-width integer constants */
# ifndef INTMAX_C
# if LONG_MAX >> 30 == 1
# define INTMAX_C(x) x##LL
# elif defined GL_INT64_T
# define INTMAX_C(x) INT64_C(x)
# else
# define INTMAX_C(x) x##L
# endif
# endif
# ifndef UINTMAX_C
# if ULONG_MAX >> 31 == 1
# define UINTMAX_C(x) x##ULL
# elif defined GL_UINT64_T
# define UINTMAX_C(x) UINT64_C(x)
# else
# define UINTMAX_C(x) x##UL
# endif
# endif
#endif /* !0 */
/* Macros specified by ISO/IEC TS 18661-1:2014. */
#if (!defined UINTMAX_WIDTH \
&& (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
# ifdef INT8_MAX
# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
# endif
# ifdef UINT8_MAX
# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
# endif
# ifdef INT16_MAX
# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
# endif
# ifdef UINT16_MAX
# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
# endif
# ifdef INT32_MAX
# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
# endif
# ifdef UINT32_MAX
# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
# endif
# ifdef INT64_MAX
# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
# endif
# ifdef UINT64_MAX
# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
# endif
# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
# ifdef WINT_MAX
# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
# endif
# ifdef SIG_ATOMIC_MAX
# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
# endif
#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
#endif /* _GL_STDINT_H */
#endif /* !(defined __ANDROID__ && ...) */
#endif /* !defined _GL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,643 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Substitute for <sys/random.h>.
Copyright (C) 2020-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
# if __GNUC__ >= 3
#pragma GCC system_header
# endif
#ifndef _GL_SYS_RANDOM_H
#if 1
/* On uClibc < 1.0.35, <sys/random.h> assumes prior inclusion of <stddef.h>.
Do not use __UCLIBC__ here, as it might not be defined yet.
But avoid namespace pollution on glibc systems. */
# ifndef __GLIBC__
# include <stddef.h>
# endif
/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */
# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
# include <sys/types.h>
# include <stdlib.h>
# endif
/* The include_next requires a split double-inclusion guard. */
# include_next <sys/random.h>
#endif
#ifndef _GL_SYS_RANDOM_H
#define _GL_SYS_RANDOM_H
/* This file uses _GL_ATTRIBUTE_NODISCARD, GNULIB_POSIXCHECK,
HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
#include <sys/types.h>
/* Define the GRND_* constants. */
#ifndef GRND_NONBLOCK
# define GRND_NONBLOCK 1
# define GRND_RANDOM 2
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* C++ compatible function declaration macros.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
/* Begin/end the GNULIB_NAMESPACE namespace. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif
/* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some
platforms, but is declared and works fine on the platforms on which
it exists:
#if @GNULIB_FOO@
# if !@HAVE_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on all platforms,
but is broken/insufficient and needs to be replaced on some platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
* For providing a replacement for a function that exists on some platforms
but is broken/insufficient and needs to be replaced on some of them and
is additionally either missing or undeclared on some other platforms:
#if @GNULIB_FOO@
# if @REPLACE_FOO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef foo
# define foo rpl_foo
# endif
_GL_FUNCDECL_RPL (foo, ...);
_GL_CXXALIAS_RPL (foo, ...);
# else
# if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
_GL_FUNCDECL_SYS (foo, ...);
# endif
_GL_CXXALIAS_SYS (foo, ...);
# endif
_GL_CXXALIASWARN (foo);
#elif defined GNULIB_POSIXCHECK
...
#endif
*/
/* _GL_EXTERN_C declaration;
performs the declaration with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C extern "C"
#else
# define _GL_EXTERN_C extern
#endif
/* _GL_EXTERN_C_FUNC declaration;
performs the declaration of a function with C linkage. */
#if defined __cplusplus
# define _GL_EXTERN_C_FUNC extern "C"
#else
/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
are not allowed between 'extern' and the return type (see gnulib-common.m4).
*/
# define _GL_EXTERN_C_FUNC
#endif
/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
declares a replacement function, named rpl_func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
_GL_ARG_NONNULL ((1)));
Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
because
[[...]] extern "C" <declaration>;
is invalid syntax in C++.)
*/
#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
declares the system function, named func, with the given prototype,
consisting of return type, parameters, and attributes.
Although attributes are optional, the comma before them is required
for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
at the end of the declaration.
Examples:
_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
*/
#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
_GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
Wrapping rpl_func in an object with an inline conversion operator
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::rpl_func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
is to be used when func is a Microsoft deprecated alias, on native Windows.
It declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to _func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
*/
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
except that the C function rpl_func may have a slightly different
declaration. A cast is used to silence the "invalid conversion" error
that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::rpl_func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
Wrapping func in an object with an inline conversion operator
avoids a reference to func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::func; \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::func); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
except that the C function is picked among a set of overloaded functions,
namely the one with rettype2 and parameters2. Two consecutive casts
are used to silence the "cannot find a match" and "invalid conversion"
errors that would otherwise occur. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
/* The outer cast must be a reinterpret_cast.
The inner cast: When the function is defined as a set of overloaded
functions, it works as a static_cast<>, choosing the designated variant.
When the function is defined as a single variant, it works as a
reinterpret_cast<>. The parenthesized cast syntax works both ways. */
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
static const struct _gl_ ## func ## _wrapper \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
} \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN (func);
causes a warning to be emitted when ::func is used but not when
GNULIB_NAMESPACE::func is used. func must be defined without overloaded
variants. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN(func) \
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN_2(func,namespace) \
extern __typeof__ (func) func
# else
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN(func) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
causes a warning to be emitted when the given overloaded variant of ::func
is used but not when GNULIB_NAMESPACE::func is used. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.")
# else
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy
# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
#endif /* _GL_CXXDEFS_H */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers.
n = 1 stands for the first argument, n = 2 for the second argument etc. */
#ifndef _GL_ARG_NONNULL
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
# else
# define _GL_ARG_NONNULL(params)
# endif
#endif
/* The definition of _GL_WARN_ON_USE is copied here. */
/* A C macro for emitting warnings if a function is used.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
for FUNCTION which will then trigger a compiler warning containing
the text of "literal string" anywhere that function is called, if
supported by the compiler. If the compiler does not support this
feature, the macro expands to an unused extern declaration.
_GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
attribute used in _GL_WARN_ON_USE. If the compiler does not support
this feature, it expands to empty.
These macros are useful for marking a function as a potential
portability trap, with the intent that "literal string" include
instructions on the replacement function that should be used
instead.
_GL_WARN_ON_USE is for functions with 'extern' linkage.
_GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
linkage.
_GL_WARN_ON_USE should not be used more than once for a given function
in a given compilation unit (because this may generate a warning even
if the function is never called).
However, one of the reasons that a function is a portability trap is
if it has the wrong signature. Declaring FUNCTION with a different
signature in C is a compilation error, so this macro must use the
same type as any existing declaration so that programs that avoid
the problematic FUNCTION do not fail to compile merely because they
included a header that poisoned the function. But this implies that
_GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
have a declaration. Use of this macro implies that there must not
be any other macro hiding the declaration of FUNCTION; but
undefining FUNCTION first is part of the poisoning process anyway
(although for symbols that are provided only via a macro, the result
is a compilation error rather than a warning containing
"literal string"). Also note that in C++, it is only safe to use if
FUNCTION has no overloads.
For an example, it is possible to poison 'getline' by:
- adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
[getline]) in configure.ac, which potentially defines
HAVE_RAW_DECL_GETLINE
- adding this code to a header that wraps the system <stdio.h>:
#undef getline
#if HAVE_RAW_DECL_GETLINE
_GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
"not universally present; use the gnulib module getline");
#endif
It is not possible to directly poison global variables. But it is
possible to write a wrapper accessor function, and poison that
(less common usage, like &environ, will cause a compilation error
rather than issue the nice warning, but the end result of informing
the developer about their portability problem is still achieved):
#if HAVE_RAW_DECL_ENVIRON
static char ***
rpl_environ (void) { return &environ; }
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
# undef environ
# define environ (*rpl_environ ())
#endif
or better (avoiding contradictory use of 'static' and 'extern'):
#if HAVE_RAW_DECL_ENVIRON
static char ***
_GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
rpl_environ (void) { return &environ; }
# undef environ
# define environ (*rpl_environ ())
#endif
*/
#ifndef _GL_WARN_ON_USE
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__warning__ (message)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# endif
#endif
/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
function is declared with the given prototype, consisting of return type,
parameters, and attributes.
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
not work in this case. */
#ifndef _GL_WARN_ON_USE_CXX
# if !defined __cplusplus
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_ON_USE (function, msg)
# else
# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_clang function parameters_and_attributes \
__attribute__ ((__diagnose_if__ (1, msg, "warning")))
# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
extern rettype_gcc function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif
# endif
#endif
/* _GL_WARN_EXTERN_C declaration;
performs the declaration with C linkage. */
#ifndef _GL_WARN_EXTERN_C
# if defined __cplusplus
# define _GL_WARN_EXTERN_C extern "C"
# else
# define _GL_WARN_EXTERN_C extern
# endif
#endif
/* Declare overridden functions. */
#if 1
/* Fill a buffer with random bytes. */
# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef getrandom
# define getrandom rpl_getrandom
# endif
_GL_FUNCDECL_RPL (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags),
_GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags));
# else
# if !1
_GL_FUNCDECL_SYS (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags),
_GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags));
# endif
# if __GLIBC__ + (__GLIBC_MINOR__ >= 25) > 2
_GL_CXXALIASWARN (getrandom);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getrandom
# if HAVE_RAW_DECL_GETRANDOM
_GL_WARN_ON_USE (getrandom, "getrandom is unportable - "
"use gnulib module getrandom for portability");
# endif
#endif
#endif /* _GL_SYS_RANDOM_H */
#endif /* _GL_SYS_RANDOM_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,123 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Provide a more complete sys/types.h.
Copyright (C) 2011-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
/* This file uses #include_next of a system file that defines time_t.
For the 'year2038' module to work right, <config.h> needs to have been
included before. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
#if defined _WIN32 && !defined __CYGWIN__ \
&& (defined __need_off_t || defined __need___off64_t \
|| defined __need_ssize_t || defined __need_time_t)
/* Special invocation convention inside mingw header files. */
#include_next <sys/types.h>
#else
/* Normal invocation convention. */
#ifndef _GL_SYS_TYPES_H
/* The include_next requires a split double-inclusion guard. */
# define _GL_INCLUDING_SYS_TYPES_H
#include_next <sys/types.h>
# undef _GL_INCLUDING_SYS_TYPES_H
#ifndef _GL_SYS_TYPES_H
#define _GL_SYS_TYPES_H
/* Override off_t if Large File Support is requested on native Windows. */
#if 0
/* Same as int64_t in <stdint.h>. */
# if defined _MSC_VER
# define off_t __int64
# else
# define off_t long long int
# endif
/* Indicator, for gnulib internal purposes. */
# define _GL_WINDOWS_64_BIT_OFF_T 1
#endif
/* Define the off64_t type. */
#if !1
# if !GNULIB_defined_off64_t
/* Define off64_t to int64_t always. */
typedef long long off64_t;
# define GNULIB_defined_off64_t 1
# endif
#endif
/* Override dev_t and ino_t if distinguishable inodes support is requested
on native Windows. */
#if 0
# if 0 == 2
/* Experimental, not useful in Windows 10. */
/* Define dev_t to a 64-bit type. */
# if !defined GNULIB_defined_dev_t
typedef unsigned long long int rpl_dev_t;
# undef dev_t
# define dev_t rpl_dev_t
# define GNULIB_defined_dev_t 1
# endif
/* Define ino_t to a 128-bit type. */
# if !defined GNULIB_defined_ino_t
/* MSVC does not have a 128-bit integer type.
GCC has a 128-bit integer type __int128, but only on 64-bit targets. */
typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t;
# undef ino_t
# define ino_t rpl_ino_t
# define GNULIB_defined_ino_t 1
# endif
# else /* 0 == 1 */
/* Define ino_t to a 64-bit type. */
# if !defined GNULIB_defined_ino_t
typedef unsigned long long int rpl_ino_t;
# undef ino_t
# define ino_t rpl_ino_t
# define GNULIB_defined_ino_t 1
# endif
# endif
/* Indicator, for gnulib internal purposes. */
# define _GL_WINDOWS_STAT_INODES 0
#endif
/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
/* But avoid namespace pollution on glibc systems. */
#if (defined _WIN32 && ! defined __CYGWIN__) && ! defined __GLIBC__
# include <stddef.h>
#endif
#endif /* _GL_SYS_TYPES_H */
#endif /* _GL_SYS_TYPES_H */
#endif /* __need_XXX */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,72 +0,0 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Elementary types and macros for the GNU UniString library.
Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _UNITYPES_H
#define _UNITYPES_H
/* Get uint8_t, uint16_t, uint32_t. */
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Type representing a Unicode character. */
typedef uint32_t ucs4_t;
/* Attribute of a function whose result depends only on the arguments
(not pointers!) and which has no side effects. */
#ifndef _UC_ATTRIBUTE_CONST
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__
# define _UC_ATTRIBUTE_CONST __attribute__ ((__const__))
# else
# define _UC_ATTRIBUTE_CONST
# endif
#endif
/* Attribute of a function whose result depends only on the arguments
(possibly pointers) and global memory, and which has no side effects. */
#ifndef _UC_ATTRIBUTE_PURE
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
# define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
# define _UC_ATTRIBUTE_PURE
# endif
#endif
/* Qualifier in a function declaration, that asserts that the caller must
pass a pointer to a different object in the specified pointer argument
than in the other pointer arguments. */
#ifndef _UC_RESTRICT
# if defined __restrict \
|| 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
|| __clang_major__ >= 3
# define _UC_RESTRICT __restrict
# elif 199901L <= __STDC_VERSION__ || defined restrict
# define _UC_RESTRICT restrict
# else
# define _UC_RESTRICT
# endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _UNITYPES_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,40 +0,0 @@
# By YZBruh
# Copyright 2024 Partition Manager
#
# Licensed 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.
########
# 3.0.2
########
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libcharset
LOCAL_SRC_FILES := \
$(LOCAL_PATH)/lib/localcharset.c \
$(LOCAL_PATH)/lib/relocatable-stub.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../include/libcharset
LOCAL_CFLAGS := \
-Wall \
-Wextra \
-Wno-sign-compare \
-Wno-unused-const-variable \
-Wno-unused-parameter \
-fPIC \
-g \
-fvisibility=hidden
include $(BUILD_STATIC_LIBRARY)

View File

@@ -1,68 +0,0 @@
# By YZBruh
# Copyright 2024 Partition Manager
#
# Licensed 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.
#####
# sub-make for building libcharset (built-in lib)
#####
include ../../../build/config/env.mk
ifeq ($(INC_OLDENV),true)
include ../../../build/config/oldenv.mk
endif
E := @ echo
INCLUDE_DIR := $(CURDIR)/../../../include/libcharset
CFLAGS := \
-Wall \
-Wextra \
-Wno-sign-compare \
-Wno-unused-const-variable \
-Wno-unused-parameter \
-fPIC \
-g \
-fvisibility=hidden \
-I$(INCLUDE_DIR)
AR_FLAGS := rcs
OUT := $(realpath ../../../out/parted)
LIB := $(CURDIR)/lib
LIBCHARSET_SRCS := \
$(LIB)/localcharset.c \
$(LIB)/relocatable-stub.c
LIBCHARSET_OBJS := $(LIBCHARSET_SRCS:.c=.o)
PROGRESS_LIST := \
outctrl \
$(LIBCHARSET_OBJS) \
libcharset_ar
.PHONY: all
all: $(PROGRESS_LIST)
.PHONY: clean
clean:
@ rm -f $(LIBCHARSET_OBJS) $(OUT)/libcharset.a
outctrl:
@ if [ ! -d $(OUT) ]; then mkdir -p $(OUT); fi
$(LIB)/%.o: $(LIB)/%.c
$(E) " CC libcharset/lib/`basename $@`"
@ $(CC) -c $(CFLAGS) -o $@ $^ || exit 1
libcharset_ar: $(LIBCHARSET_OBJS)
$(E) " AR out/parted/libcharset.a"
@ $(AR) $(AR_FLAGS) $(OUT)/libcharset.a $(LIBCHARSET_OBJS)

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +0,0 @@
/* Provide relocatable packages.
Copyright (C) 2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2018.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "libcharset.h"
extern LIBCHARSET_DLL_EXPORTED void
libcharset_set_relocation_prefix (const char *orig_prefix, const char *curr_prefix);
/* This is a stub for binary backward-compatibility. */
void
libcharset_set_relocation_prefix (const char *orig_prefix, const char *curr_prefix)
{
}

View File

@@ -1,97 +0,0 @@
# By YZBruh
# Copyright 2024 Partition Manager
#
# Licensed 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.
########
# 3.0.2
########
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libgnulib
LOCAL_SRC_FILES := \
$(LOCAL_PATH)/lib/argmatch.c \
$(LOCAL_PATH)/lib/basename-lgpl.c \
$(LOCAL_PATH)/lib/basename.c \
$(LOCAL_PATH)/lib/btowc.c \
$(LOCAL_PATH)/lib/c-ctype.c \
$(LOCAL_PATH)/lib/c-strcasecmp.c \
$(LOCAL_PATH)/lib/c-strncasecmp.c \
$(LOCAL_PATH)/lib/c32isprint.c \
$(LOCAL_PATH)/lib/canonicalize-lgpl.c \
$(LOCAL_PATH)/lib/cloexec.c \
$(LOCAL_PATH)/lib/close-stream.c \
$(LOCAL_PATH)/lib/closeout.c \
$(LOCAL_PATH)/lib/dirname-lgpl.c \
$(LOCAL_PATH)/lib/dirname.c \
$(LOCAL_PATH)/lib/error.c \
$(LOCAL_PATH)/lib/exitfail.c \
$(LOCAL_PATH)/lib/fcntl.c \
$(LOCAL_PATH)/lib/free.c \
$(LOCAL_PATH)/lib/getdtablesize.c \
$(LOCAL_PATH)/lib/hard-locale.c \
$(LOCAL_PATH)/lib/ialloc.c \
$(LOCAL_PATH)/lib/iswctype.c \
$(LOCAL_PATH)/lib/iswdigit.c \
$(LOCAL_PATH)/lib/iswpunct.c \
$(LOCAL_PATH)/lib/iswxdigit.c \
$(LOCAL_PATH)/lib/localcharset.c \
$(LOCAL_PATH)/lib/long-options.c \
$(LOCAL_PATH)/lib/malloca.c \
$(LOCAL_PATH)/lib/mbrtoc32.c \
$(LOCAL_PATH)/lib/mbrtowc.c \
$(LOCAL_PATH)/lib/mbszero.c \
$(LOCAL_PATH)/lib/nl_langinfo.c \
$(LOCAL_PATH)/lib/progname.c \
$(LOCAL_PATH)/lib/quotearg.c \
$(LOCAL_PATH)/lib/rawmemchr.c \
$(LOCAL_PATH)/lib/regex.c \
$(LOCAL_PATH)/lib/rpmatch.c \
$(LOCAL_PATH)/lib/safe-read.c \
$(LOCAL_PATH)/lib/setlocale-lock.c \
$(LOCAL_PATH)/lib/setlocale_null-unlocked.c \
$(LOCAL_PATH)/lib/setlocale_null.c \
$(LOCAL_PATH)/lib/stat-time.c \
$(LOCAL_PATH)/lib/stripslash.c \
$(LOCAL_PATH)/lib/tempname.c \
$(LOCAL_PATH)/lib/version-etc-fsf.c \
$(LOCAL_PATH)/lib/version-etc.c \
$(LOCAL_PATH)/lib/wctype.c \
$(LOCAL_PATH)/lib/unictype/ctype_print.c \
$(LOCAL_PATH)/lib/xalloc-die.c \
$(LOCAL_PATH)/lib/xmalloc.c \
$(LOCAL_PATH)/lib/xstrtol.c \
$(LOCAL_PATH)/lib/xstrtoll.c \
$(LOCAL_PATH)/lib/xstrtoul.c \
$(LOCAL_PATH)/lib/xstrtoull.c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../../include/libgnulib \
$(LOCAL_PATH)/../../../include \
$(LOCAL_PATH)/../lib \
$(LOCAL_PATH)/lib
LOCAL_CFLAGS := \
-Wall \
-Wextra \
-Wno-sign-compare \
-Wno-unused-const-variable \
-Wno-unused-parameter \
-Wno-nullability-completeness \
-Wno-macro-redefined \
-fPIC \
-include $(LOCAL_PATH)/../../include/PartitionManager/Alternatives.h
include $(BUILD_STATIC_LIBRARY)

View File

@@ -1,293 +0,0 @@
/* argmatch.c -- find a match for a string in an array
Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2024 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by David MacKenzie <djm@ai.mit.edu>
Modified by Akim Demaille <demaille@inf.enst.fr> */
#include <config.h>
/* Specification. */
#include "argmatch.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _(msgid) gettext (msgid)
#include <error.h>
#include "quotearg.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
/* When reporting an invalid argument, show nonprinting characters
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
literal_quoting_style. */
#ifndef ARGMATCH_QUOTING_STYLE
# define ARGMATCH_QUOTING_STYLE locale_quoting_style
#endif
/* Non failing version of argmatch call this function after failing. */
#ifndef ARGMATCH_DIE
# include "exitfail.h"
# define ARGMATCH_DIE exit (exit_failure)
#endif
#ifdef ARGMATCH_DIE_DECL
ARGMATCH_DIE_DECL;
#endif
static void
__argmatch_die (void)
{
ARGMATCH_DIE;
}
/* Used by XARGMATCH. See description in argmatch.h.
Default to __argmatch_die, but allow caller to change this at run-time. */
argmatch_exit_fn argmatch_die = __argmatch_die;
/* If ARG is an unambiguous match for an element of the
NULL-terminated array ARGLIST, return the index in ARGLIST
of the matched element, else -1 if it does not match any element
or -2 if it is ambiguous (is a prefix of more than one element).
If VALLIST is none null, use it to resolve ambiguities limited to
synonyms, i.e., for
"yes", "yop" -> 0
"no", "nope" -> 1
"y" is a valid argument, for 0, and "n" for 1. */
ptrdiff_t
argmatch (const char *arg, const char *const *arglist,
const void *vallist, size_t valsize)
{
size_t i; /* Temporary index in ARGLIST. */
size_t arglen; /* Length of ARG. */
ptrdiff_t matchind = -1; /* Index of first nonexact match. */
bool ambiguous = false; /* If true, multiple nonexact match(es). */
arglen = strlen (arg);
/* Test all elements for either exact match or abbreviated matches. */
for (i = 0; arglist[i]; i++)
{
if (!strncmp (arglist[i], arg, arglen))
{
if (strlen (arglist[i]) == arglen)
/* Exact match found. */
return i;
else if (matchind == -1)
/* First nonexact match found. */
matchind = i;
else
{
/* Second nonexact match found. */
if (vallist == NULL
|| memcmp ((char const *) vallist + valsize * matchind,
(char const *) vallist + valsize * i, valsize))
{
/* There is a real ambiguity, or we could not
disambiguate. */
ambiguous = true;
}
}
}
}
if (ambiguous)
return -2;
else
return matchind;
}
ptrdiff_t
argmatch_exact (const char *arg, const char *const *arglist)
{
size_t i;
/* Test elements for exact match. */
for (i = 0; arglist[i]; i++)
{
if (!strcmp (arglist[i], arg))
return i;
}
return -1;
}
/* Error reporting for argmatch.
CONTEXT is a description of the type of entity that was being matched.
VALUE is the invalid value that was given.
PROBLEM is the return value from argmatch. */
void
argmatch_invalid (const char *context, const char *value, ptrdiff_t problem)
{
char const *format = (problem == -1
? _("invalid argument %s for %s")
: _("ambiguous argument %s for %s"));
error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
quote_n (1, context));
}
/* List the valid arguments for argmatch.
ARGLIST is the same as in argmatch.
VALLIST is a pointer to an array of values.
VALSIZE is the size of the elements of VALLIST */
void
argmatch_valid (const char *const *arglist,
const void *vallist, size_t valsize)
{
size_t i;
const char *last_val = NULL;
/* We try to put synonyms on the same line. The assumption is that
synonyms follow each other */
fputs (_("Valid arguments are:"), stderr);
for (i = 0; arglist[i]; i++)
if ((i == 0)
|| memcmp (last_val, (char const *) vallist + valsize * i, valsize))
{
fprintf (stderr, "\n - %s", quote (arglist[i]));
last_val = (char const *) vallist + valsize * i;
}
else
{
fprintf (stderr, ", %s", quote (arglist[i]));
}
putc ('\n', stderr);
}
/* Never failing versions of the previous functions.
CONTEXT is the context for which argmatch is called (e.g.,
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
calls the (supposed never to return) function EXIT_FN. */
ptrdiff_t
__xargmatch_internal (const char *context,
const char *arg, const char *const *arglist,
const void *vallist, size_t valsize,
argmatch_exit_fn exit_fn,
bool allow_abbreviation)
{
ptrdiff_t res;
if (allow_abbreviation)
res = argmatch (arg, arglist, vallist, valsize);
else
res = argmatch_exact (arg, arglist);
if (res >= 0)
/* Success. */
return res;
/* We failed. Explain why. */
argmatch_invalid (context, arg, res);
argmatch_valid (arglist, vallist, valsize);
(*exit_fn) ();
return -1; /* To please the compilers. */
}
/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
return the first corresponding argument in ARGLIST */
const char *
argmatch_to_argument (const void *value,
const char *const *arglist,
const void *vallist, size_t valsize)
{
size_t i;
for (i = 0; arglist[i]; i++)
if (!memcmp (value, (char const *) vallist + valsize * i, valsize))
return arglist[i];
return NULL;
}
#ifdef TEST
/*
* Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
*/
/* When to make backup files. */
enum backup_type
{
/* Never make backups. */
no_backups,
/* Make simple backups of every file. */
simple_backups,
/* Make numbered backups of files that already have numbered backups,
and simple backups of the others. */
numbered_existing_backups,
/* Make numbered backups of every file. */
numbered_backups
};
/* Two tables describing arguments (keys) and their corresponding
values */
static const char *const backup_args[] =
{
"no", "none", "off",
"simple", "never",
"existing", "nil",
"numbered", "t",
0
};
static const enum backup_type backup_vals[] =
{
no_backups, no_backups, no_backups,
simple_backups, simple_backups,
numbered_existing_backups, numbered_existing_backups,
numbered_backups, numbered_backups
};
int
main (int argc, const char *const *argv)
{
const char *cp;
enum backup_type backup_type = no_backups;
if (argc > 2)
{
fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", getprogname ());
exit (1);
}
if ((cp = getenv ("VERSION_CONTROL")))
backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
backup_args, backup_vals);
if (argc == 2)
backup_type = XARGMATCH (getprogname (), argv[1],
backup_args, backup_vals);
printf ("The version control is '%s'\n",
ARGMATCH_TO_ARGUMENT (&backup_type, backup_args, backup_vals));
return 0;
}
#endif

View File

@@ -1,70 +0,0 @@
/* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include "basename-lgpl.h"
#include <string.h>
#include "filename.h"
char *
last_component (char const *name)
{
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
char const *p;
bool last_was_slash = false;
while (ISSLASH (*base))
base++;
for (p = base; *p; p++)
{
if (ISSLASH (*p))
last_was_slash = true;
else if (last_was_slash)
{
base = p;
last_was_slash = false;
}
}
return (char *) base;
}
size_t
base_len (char const *name)
{
size_t len;
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
continue;
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
&& ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
return 2;
if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
&& len == prefix_len && ISSLASH (name[prefix_len]))
return prefix_len + 1;
return len;
}

View File

@@ -1,64 +0,0 @@
/* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "dirname.h"
#include <string.h>
#include "xalloc.h"
char *
base_name (char const *name)
{
char const *base = last_component (name);
idx_t length;
int dotslash_len;
if (*base)
{
length = base_len (base);
/* Collapse a sequence of trailing slashes into one. */
length += ISSLASH (base[length]);
/* On systems with drive letters, "a/b:c" must return "./b:c" rather
than "b:c" to avoid confusion with a drive letter. On systems
with pure POSIX semantics, this is not an issue. */
dotslash_len = FILE_SYSTEM_PREFIX_LEN (base) != 0 ? 2 : 0;
}
else
{
/* There is no last component, so NAME is a file system root or
the empty string. */
base = name;
length = base_len (base);
dotslash_len = 0;
}
char *p = ximalloc (dotslash_len + length + 1);
if (dotslash_len)
{
p[0] = '.';
p[1] = '/';
}
/* Finally, copy the basename. */
memcpy (p + dotslash_len, base, length);
p[dotslash_len + length] = '\0';
return p;
}

View File

@@ -1,47 +0,0 @@
/* Convert unibyte character to wide character.
Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
wint_t
btowc (int c)
{
if (c != EOF)
{
char buf[1];
wchar_t wc;
buf[0] = c;
#if HAVE_MBRTOWC
mbstate_t state;
mbszero (&state);
size_t ret = mbrtowc (&wc, buf, 1, &state);
if (!(ret == (size_t)(-1) || ret == (size_t)(-2)))
#else
if (mbtowc (&wc, buf, 1) >= 0)
#endif
return wc;
}
return WEOF;
}

View File

@@ -1,21 +0,0 @@
/* Character handling in C locale.
Copyright (C) 2003-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#define C_CTYPE_INLINE _GL_EXTERN_INLINE
#include "c-ctype.h"

View File

@@ -1,56 +0,0 @@
/* c-strcasecmp.c -- case insensitive string comparator in C locale
Copyright (C) 1998-1999, 2005-2006, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include "c-strcase.h"
#include <limits.h>
#include "c-ctype.h"
int
c_strcasecmp (const char *s1, const char *s2)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2)
return 0;
do
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
if (c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return _GL_CMP (c1, c2);
}

View File

@@ -1,56 +0,0 @@
/* c-strncasecmp.c -- case insensitive string comparator in C locale
Copyright (C) 1998-1999, 2005-2006, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include "c-strcase.h"
#include <limits.h>
#include "c-ctype.h"
int
c_strncasecmp (const char *s1, const char *s2, size_t n)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2 || n == 0)
return 0;
do
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
if (--n == 0 || c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return _GL_CMP (c1, c2);
}

View File

@@ -1,26 +0,0 @@
/* Test 32-bit wide character for being printable.
Copyright (C) 2020-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#define IN_C32ISPRINT
/* Specification. */
#include <uchar.h>
#define FUNC c32isprint
#define WCHAR_FUNC iswprint
#define UCS_FUNC uc_is_print
#include "c32is-impl.h"

View File

@@ -1,469 +0,0 @@
/* Return the canonical absolute name of a given file.
Copyright (C) 1996-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _LIBC
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
optimizes away the name == NULL test below. */
# define _GL_ARG_NONNULL(params)
# include <libc-config.h>
#endif
/* Specification. */
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <eloop-threshold.h>
#include <filename.h>
#include <idx.h>
#include <intprops.h>
#include <scratch_buffer.h>
#ifdef _LIBC
# include <shlib-compat.h>
# define GCC_LINT 1
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
#else
# define __canonicalize_file_name canonicalize_file_name
# define __realpath realpath
# define __strdup strdup
# include "pathmax.h"
# define __faccessat faccessat
# if defined _WIN32 && !defined __CYGWIN__
# define __getcwd _getcwd
# elif HAVE_GETCWD
# if IN_RELOCWRAPPER
/* When building the relocatable program wrapper, use the system's getcwd
function, not the gnulib override, otherwise we would get a link error.
*/
# undef getcwd
# endif
# if defined VMS && !defined getcwd
/* We want the directory in Unix syntax, not in VMS syntax.
The gnulib override of 'getcwd' takes 2 arguments; the original VMS
'getcwd' takes 3 arguments. */
# define __getcwd(buf, max) getcwd (buf, max, 0)
# else
# define __getcwd getcwd
# endif
# else
# define __getcwd(buf, max) getwd (buf)
# endif
# define __mempcpy mempcpy
# define __pathconf pathconf
# define __rawmemchr rawmemchr
# define __readlink readlink
# if IN_RELOCWRAPPER
/* When building the relocatable program wrapper, use the system's memmove
function, not the gnulib override, otherwise we would get a link error.
*/
# undef memmove
# endif
#endif
/* Suppress bogus GCC -Wmaybe-uninitialized warnings. */
#if defined GCC_LINT || defined lint
# define IF_LINT(Code) Code
#else
# define IF_LINT(Code) /* empty */
#endif
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
# define DOUBLE_SLASH_IS_DISTINCT_ROOT false
#endif
#if defined _LIBC || !FUNC_REALPATH_WORKS
/* Return true if FILE's existence can be shown, false (setting errno)
otherwise. Follow symbolic links. */
static bool
file_accessible (char const *file)
{
# if defined _LIBC || HAVE_FACCESSAT
return __faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) == 0;
# else
struct stat st;
return stat (file, &st) == 0 || errno == EOVERFLOW;
# endif
}
/* True if concatenating END as a suffix to a file name means that the
code needs to check that the file name is that of a searchable
directory, since the canonicalize_filename_mode_stk code won't
check this later anyway when it checks an ordinary file name
component within END. END must either be empty, or start with a
slash. */
static bool _GL_ATTRIBUTE_PURE
suffix_requires_dir_check (char const *end)
{
/* If END does not start with a slash, the suffix is OK. */
while (ISSLASH (*end))
{
/* Two or more slashes act like a single slash. */
do
end++;
while (ISSLASH (*end));
switch (*end++)
{
default: return false; /* An ordinary file name component is OK. */
case '\0': return true; /* Trailing "/" is trouble. */
case '.': break; /* Possibly "." or "..". */
}
/* Trailing "/.", or "/.." even if not trailing, is trouble. */
if (!*end || (*end == '.' && (!end[1] || ISSLASH (end[1]))))
return true;
}
return false;
}
/* Append this to a file name to test whether it is a searchable directory.
On POSIX platforms "/" suffices, but "/./" is sometimes needed on
macOS 10.13 <https://bugs.gnu.org/30350>, and should also work on
platforms like AIX 7.2 that need at least "/.". */
# if defined _LIBC || defined LSTAT_FOLLOWS_SLASHED_SYMLINK
static char const dir_suffix[] = "/";
# else
static char const dir_suffix[] = "/./";
# endif
/* Return true if DIR is a searchable dir, false (setting errno) otherwise.
DIREND points to the NUL byte at the end of the DIR string.
Store garbage into DIREND[0 .. strlen (dir_suffix)]. */
static bool
dir_check (char *dir, char *dirend)
{
strcpy (dirend, dir_suffix);
return file_accessible (dir);
}
static idx_t
get_path_max (void)
{
# ifdef PATH_MAX
long int path_max = PATH_MAX;
# else
/* The caller invoked realpath with a null RESOLVED, even though
PATH_MAX is not defined as a constant. The glibc manual says
programs should not do this, and POSIX says the behavior is undefined.
Historically, glibc here used the result of pathconf, or 1024 if that
failed; stay consistent with this (dubious) historical practice. */
int err = errno;
long int path_max = __pathconf ("/", _PC_PATH_MAX);
__set_errno (err);
# endif
return path_max < 0 ? 1024 : path_max <= IDX_MAX ? path_max : IDX_MAX;
}
/* Scratch buffers used by realpath_stk and managed by __realpath. */
struct realpath_bufs
{
struct scratch_buffer rname;
struct scratch_buffer extra;
struct scratch_buffer link;
};
static char *
realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
{
char *dest;
char const *start;
char const *end;
int num_links = 0;
if (name == NULL)
{
/* As per Single Unix Specification V2 we must return an error if
either parameter is a null pointer. We extend this to allow
the RESOLVED parameter to be NULL in case the we are expected to
allocate the room for the return value. */
__set_errno (EINVAL);
return NULL;
}
if (name[0] == '\0')
{
/* As per Single Unix Specification V2 we must return an error if
the name argument points to an empty string. */
__set_errno (ENOENT);
return NULL;
}
char *rname = bufs->rname.data;
bool end_in_extra_buffer = false;
bool failed = true;
/* This is always zero for Posix hosts, but can be 2 for MS-Windows
and MS-DOS X:/foo/bar file names. */
idx_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
if (!IS_ABSOLUTE_FILE_NAME (name))
{
while (!__getcwd (bufs->rname.data, bufs->rname.length))
{
if (errno != ERANGE)
{
dest = rname;
goto error;
}
if (!scratch_buffer_grow (&bufs->rname))
return NULL;
rname = bufs->rname.data;
}
dest = __rawmemchr (rname, '\0');
start = name;
prefix_len = FILE_SYSTEM_PREFIX_LEN (rname);
}
else
{
dest = __mempcpy (rname, name, prefix_len);
*dest++ = '/';
if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
{
if (prefix_len == 0 /* implies ISSLASH (name[0]) */
&& ISSLASH (name[1]) && !ISSLASH (name[2]))
*dest++ = '/';
*dest = '\0';
}
start = name + prefix_len;
}
for ( ; *start; start = end)
{
/* Skip sequence of multiple file name separators. */
while (ISSLASH (*start))
++start;
/* Find end of component. */
for (end = start; *end && !ISSLASH (*end); ++end)
/* Nothing. */;
/* Length of this file name component; it can be zero if a file
name ends in '/'. */
idx_t startlen = end - start;
if (startlen == 0)
break;
else if (startlen == 1 && start[0] == '.')
/* nothing */;
else if (startlen == 2 && start[0] == '.' && start[1] == '.')
{
/* Back up to previous component, ignore if at root already. */
if (dest > rname + prefix_len + 1)
for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
continue;
if (DOUBLE_SLASH_IS_DISTINCT_ROOT
&& dest == rname + 1 && !prefix_len
&& ISSLASH (*dest) && !ISSLASH (dest[1]))
dest++;
}
else
{
if (!ISSLASH (dest[-1]))
*dest++ = '/';
while (rname + bufs->rname.length - dest
< startlen + sizeof dir_suffix)
{
idx_t dest_offset = dest - rname;
if (!scratch_buffer_grow_preserve (&bufs->rname))
return NULL;
rname = bufs->rname.data;
dest = rname + dest_offset;
}
dest = __mempcpy (dest, start, startlen);
*dest = '\0';
char *buf;
ssize_t n;
while (true)
{
buf = bufs->link.data;
idx_t bufsize = bufs->link.length;
n = __readlink (rname, buf, bufsize - 1);
if (n < bufsize - 1)
break;
if (!scratch_buffer_grow (&bufs->link))
return NULL;
}
if (0 <= n)
{
if (++num_links > __eloop_threshold ())
{
__set_errno (ELOOP);
goto error;
}
buf[n] = '\0';
char *extra_buf = bufs->extra.data;
idx_t end_idx IF_LINT (= 0);
if (end_in_extra_buffer)
end_idx = end - extra_buf;
size_t len = strlen (end);
if (INT_ADD_OVERFLOW (len, n))
{
__set_errno (ENOMEM);
return NULL;
}
while (bufs->extra.length <= len + n)
{
if (!scratch_buffer_grow_preserve (&bufs->extra))
return NULL;
extra_buf = bufs->extra.data;
}
if (end_in_extra_buffer)
end = extra_buf + end_idx;
/* Careful here, end may be a pointer into extra_buf... */
memmove (&extra_buf[n], end, len + 1);
name = end = memcpy (extra_buf, buf, n);
end_in_extra_buffer = true;
if (IS_ABSOLUTE_FILE_NAME (buf))
{
idx_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf);
dest = __mempcpy (rname, buf, pfxlen);
*dest++ = '/'; /* It's an absolute symlink */
if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
{
if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen)
*dest++ = '/';
*dest = '\0';
}
/* Install the new prefix to be in effect hereafter. */
prefix_len = pfxlen;
}
else
{
/* Back up to previous component, ignore if at root
already: */
if (dest > rname + prefix_len + 1)
for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
continue;
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
&& ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
dest++;
}
}
else if (! (suffix_requires_dir_check (end)
? dir_check (rname, dest)
: errno == EINVAL))
goto error;
}
}
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
--dest;
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && !prefix_len
&& ISSLASH (*dest) && !ISSLASH (dest[1]))
dest++;
failed = false;
error:
*dest++ = '\0';
if (resolved != NULL)
{
/* Copy the full result on success or partial result if failure was due
to the path not existing or not being accessible. */
if ((!failed || errno == ENOENT || errno == EACCES)
&& dest - rname <= get_path_max ())
{
strcpy (resolved, rname);
if (failed)
return NULL;
else
return resolved;
}
if (!failed)
__set_errno (ENAMETOOLONG);
return NULL;
}
else
{
if (failed)
return NULL;
else
return __strdup (bufs->rname.data);
}
}
/* Return the canonical absolute name of file NAME. A canonical name
does not contain any ".", ".." components nor any repeated file name
separators ('/') or symlinks. All file name components must exist. If
RESOLVED is null, the result is malloc'd; otherwise, if the
canonical name is PATH_MAX chars or more, returns null with 'errno'
set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
returns the name in RESOLVED. If the name cannot be resolved and
RESOLVED is non-NULL, it contains the name of the first component
that cannot be resolved. If the name can be resolved, RESOLVED
holds the same value as the value returned. */
char *
__realpath (const char *name, char *resolved)
{
struct realpath_bufs bufs;
scratch_buffer_init (&bufs.rname);
scratch_buffer_init (&bufs.extra);
scratch_buffer_init (&bufs.link);
char *result = realpath_stk (name, resolved, &bufs);
scratch_buffer_free (&bufs.link);
scratch_buffer_free (&bufs.extra);
scratch_buffer_free (&bufs.rname);
return result;
}
libc_hidden_def (__realpath)
versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
#endif /* defined _LIBC || !FUNC_REALPATH_WORKS */
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3)
char *
attribute_compat_text_section
__old_realpath (const char *name, char *resolved)
{
if (resolved == NULL)
{
__set_errno (EINVAL);
return NULL;
}
return __realpath (name, resolved);
}
compat_symbol (libc, __old_realpath, realpath, GLIBC_2_0);
#endif
char *
__canonicalize_file_name (const char *name)
{
return __realpath (name, NULL);
}
weak_alias (__canonicalize_file_name, canonicalize_file_name)

View File

@@ -1,83 +0,0 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
Copyright (C) 1991, 2004-2006, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* The code is taken from glibc/manual/llio.texi */
#include <config.h>
#include "cloexec.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
or clear the flag if VALUE is false.
Return 0 on success, or -1 on error with 'errno' set.
Note that on MingW, this function does NOT protect DESC from being
inherited into spawned children. Instead, either use dup_cloexec
followed by closing the original DESC, or use interfaces such as
open or pipe2 that accept flags like O_CLOEXEC to create DESC
non-inheritable in the first place. */
int
set_cloexec_flag (int desc, bool value)
{
#ifdef F_SETFD
int flags = fcntl (desc, F_GETFD, 0);
if (0 <= flags)
{
int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
if (flags == newflags
|| fcntl (desc, F_SETFD, newflags) != -1)
return 0;
}
return -1;
#else /* !F_SETFD */
/* Use dup2 to reject invalid file descriptors; the cloexec flag
will be unaffected. */
if (desc < 0)
{
errno = EBADF;
return -1;
}
if (dup2 (desc, desc) < 0)
/* errno is EBADF here. */
return -1;
/* There is nothing we can do on this kind of platform. Punt. */
return 0;
#endif /* !F_SETFD */
}
/* Duplicates a file handle FD, while marking the copy to be closed
prior to exec or spawn. Returns -1 and sets errno if FD could not
be duplicated. */
int
dup_cloexec (int fd)
{
return fcntl (fd, F_DUPFD_CLOEXEC, 0);
}

View File

@@ -1,77 +0,0 @@
/* Close a stream, with nicer error checking than fclose's.
Copyright (C) 1998-2002, 2004, 2006-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "close-stream.h"
#include <errno.h>
#include "fpending.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
/* Close STREAM. Return 0 if successful, EOF (setting errno)
otherwise. A failure might set errno to 0 if the error number
cannot be determined.
A failure with errno set to EPIPE may or may not indicate an error
situation worth signaling to the user. See the documentation of the
close_stdout_set_ignore_EPIPE function for details.
If a program writes *anything* to STREAM, that program should close
STREAM and make sure that it succeeds before exiting. Otherwise,
suppose that you go to the extreme of checking the return status
of every function that does an explicit write to STREAM. The last
printf can succeed in writing to the internal stream buffer, and yet
the fclose(STREAM) could still fail (due e.g., to a disk full error)
when it tries to write out that buffered data. Thus, you would be
left with an incomplete output file and the offending program would
exit successfully. Even calling fflush is not always sufficient,
since some file systems (NFS and CODA) buffer written/flushed data
until an actual close call.
Besides, it's wasteful to check the return value from every call
that writes to STREAM -- just let the internal stream state record
the failure. That's what the ferror test is checking below. */
int
close_stream (FILE *stream)
{
const bool some_pending = (__fpending (stream) != 0);
const bool prev_fail = (ferror (stream) != 0);
const bool fclose_fail = (fclose (stream) != 0);
/* Return an error indication if there was a previous failure or if
fclose failed, with one exception: ignore an fclose failure if
there was no previous error, no data remains to be flushed, and
fclose failed with EBADF. That can happen when a program like cp
is invoked like this 'cp a b >&-' (i.e., with standard output
closed) and doesn't generate any output (hence no previous error
and nothing to be flushed). */
if (prev_fail || (fclose_fail && (some_pending || errno != EBADF)))
{
if (! fclose_fail)
errno = 0;
return EOF;
}
return 0;
}

View File

@@ -1,135 +0,0 @@
/* Close standard output and standard error, exiting with a diagnostic on error.
Copyright (C) 1998-2002, 2004, 2006, 2008-2024 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "closeout.h"
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "close-stream.h"
#include <error.h>
#include "exitfail.h"
#include "quotearg.h"
#ifndef __has_feature
# define __has_feature(a) false
#endif
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
enum { SANITIZE_ADDRESS = true };
#else
enum { SANITIZE_ADDRESS = false };
#endif
static const char *file_name;
/* Set the file name to be reported in the event an error is detected
by close_stdout. */
void
close_stdout_set_file_name (const char *file)
{
file_name = file;
}
static bool ignore_EPIPE /* = false */;
/* Specify the reaction to an EPIPE error during the closing of stdout:
- If ignore = true, it shall be ignored.
- If ignore = false, it shall evoke a diagnostic, along with a nonzero
exit status.
The default is ignore = false.
This setting matters only if the SIGPIPE signal is ignored (i.e. its
handler set to SIG_IGN) or blocked. Only particular programs need to
temporarily ignore SIGPIPE. If SIGPIPE is ignored or blocked because
it was ignored or blocked in the parent process when it created the
child process, it usually is a bug in the parent process: It is bad
practice to have SIGPIPE ignored or blocked while creating a child
process.
EPIPE occurs when writing to a pipe or socket that has no readers now,
when SIGPIPE is ignored or blocked.
The ignore = false setting is suitable for a scenario where it is normally
guaranteed that the pipe writer terminates before the pipe reader. In
this case, an EPIPE is an indication of a premature termination of the
pipe reader and should lead to a diagnostic and a nonzero exit status.
The ignore = true setting is suitable for a scenario where you don't know
ahead of time whether the pipe writer or the pipe reader will terminate
first. In this case, an EPIPE is an indication that the pipe writer can
stop doing useless write() calls; this is what close_stdout does anyway.
EPIPE is part of the normal pipe/socket shutdown protocol in this case,
and should not lead to a diagnostic message. */
void
close_stdout_set_ignore_EPIPE (bool ignore)
{
ignore_EPIPE = ignore;
}
/* Close standard output. On error, issue a diagnostic and _exit
with status 'exit_failure'.
Also close standard error. On error, _exit with status 'exit_failure'.
Since close_stdout is commonly registered via 'atexit', POSIX
and the C standard both say that it should not call 'exit',
because the behavior is undefined if 'exit' is called more than
once. So it calls '_exit' instead of 'exit'. If close_stdout
is registered via atexit before other functions are registered,
the other functions can act before this _exit is invoked.
Applications that use close_stdout should flush any streams
other than stdout and stderr before exiting, since the call to
_exit will bypass other buffer flushing. Applications should
be flushing and closing other streams anyway, to check for I/O
errors. Also, applications should not use tmpfile, since _exit
can bypass the removal of these files.
It's important to detect such failures and exit nonzero because many
tools (most notably 'make' and other build-management systems) depend
on being able to detect failure in other tools via their exit status. */
void
close_stdout (void)
{
if (close_stream (stdout) != 0
&& !(ignore_EPIPE && errno == EPIPE))
{
char const *write_error = _("write error");
if (file_name)
error (0, errno, "%s: %s", quotearg_colon (file_name),
write_error);
else
error (0, errno, "%s", write_error);
_exit (exit_failure);
}
/* Close stderr only if not sanitizing, as sanitizers may report to
stderr after this function returns. */
if (!SANITIZE_ADDRESS && close_stream (stderr) != 0)
_exit (exit_failure);
}

View File

@@ -1,86 +0,0 @@
/* dirname.c -- return all but the last element in a file name
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "dirname.h"
#include <stdlib.h>
#include <string.h>
/* Return the length of the prefix of FILE that will be used by
dir_name. If FILE is in the working directory, this returns zero
even though 'dir_name (FILE)' will return ".". Works properly even
if there are trailing slashes (by effectively ignoring them). */
size_t
dir_len (char const *file)
{
size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
size_t length;
/* Advance prefix_length beyond important leading slashes. */
prefix_length += (prefix_length != 0
? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
&& ISSLASH (file[prefix_length]))
: (ISSLASH (file[0])
? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
&& ISSLASH (file[1]) && ! ISSLASH (file[2])
? 2 : 1))
: 0));
/* Strip the basename and any redundant slashes before it. */
for (length = last_component (file) - file;
prefix_length < length; length--)
if (! ISSLASH (file[length - 1]))
break;
return length;
}
/* In general, we can't use the builtin 'dirname' function if available,
since it has different meanings in different environments.
In some environments the builtin 'dirname' modifies its argument.
Return the leading directories part of FILE, allocated with malloc.
Works properly even if there are trailing slashes (by effectively
ignoring them). Return NULL on failure.
If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
lstat (base_name (FILE)); } will access the same file. Likewise,
if the sequence { chdir (dir_name (FILE));
rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
to "foo" in the same directory FILE was in. */
char *
mdir_name (char const *file)
{
size_t length = dir_len (file);
bool append_dot = (length == 0
|| (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
&& length == FILE_SYSTEM_PREFIX_LEN (file)
&& file[2] != '\0' && ! ISSLASH (file[2])));
char *dir = malloc (length + append_dot + 1);
if (!dir)
return NULL;
memcpy (dir, file, length);
if (append_dot)
dir[length++] = '.';
dir[length] = '\0';
return dir;
}

View File

@@ -1,38 +0,0 @@
/* dirname.c -- return all but the last element in a file name
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "dirname.h"
#include <stdlib.h>
#include <string.h>
#include "xalloc.h"
/* Just like mdir_name (dirname-lgpl.c), except, rather than
returning NULL upon malloc failure, here, we report the
"memory exhausted" condition and exit. */
char *
dir_name (char const *file)
{
char *result = mdir_name (file);
if (!result)
xalloc_die ();
return result;
}

View File

@@ -1,375 +0,0 @@
/* Error handler for noninteractive utilities
Copyright (C) 1990-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#if !_LIBC
# include <config.h>
# define _GL_NO_INLINE_ERROR
# define __error_internal(status, err, fmt, args, flags) \
verror (status, err, fmt, args)
# define __error_at_line_internal(status, err, file, line, fmt, args, flags) \
verror_at_line (status, err, file, line, fmt, args)
# define error_tail(status, err, fmt, args, flags) \
error_tail (status, err, fmt, args)
#endif
#include <error.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !_LIBC && ENABLE_NLS
# include "gettext.h"
# define _(msgid) gettext (msgid)
#endif
#ifdef _LIBC
# include <libintl.h>
# include <stdbool.h>
# include <stdint.h>
# include <wchar.h>
# define mbsrtowcs __mbsrtowcs
# define USE_UNLOCKED_IO 0
# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b)
# define _GL_ARG_NONNULL(a)
#endif
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
#ifndef _
# define _(String) String
#endif
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
void (*error_print_progname) (void);
/* This variable is incremented each time 'error' is called. */
unsigned int error_message_count;
#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this. */
# define program_name program_invocation_name
# include <errno.h>
# include <limits.h>
# include <libio/libioP.h>
/* In GNU libc we want do not want to use the common name 'error' directly.
Instead make it a weak alias. */
extern void __error (int status, int errnum, const char *message, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
extern void __error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message,
...)
__attribute__ ((__format__ (__printf__, 5, 6)));
# define error __error
# define error_at_line __error_at_line
# include <libio/iolibio.h>
# define fflush(s) _IO_fflush (s)
# undef putc
# define putc(c, fp) _IO_putc (c, fp)
# include <libc-lock.h>
#else /* not _LIBC */
# include <fcntl.h>
# include <unistd.h>
# if defined _WIN32 && ! defined __CYGWIN__
/* Get declarations of the native Windows API functions. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
# if GNULIB_MSVC_NOTHROW
# include "msvc-nothrow.h"
# else
# include <io.h>
# endif
# endif
/* The gnulib override of fcntl is not needed in this file. */
# undef fcntl
# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
# ifndef HAVE_DECL_STRERROR_R
"this configure-time declaration test was not run"
# endif
# if STRERROR_R_CHAR_P
char *strerror_r (int errnum, char *buf, size_t buflen);
# else
int strerror_r (int errnum, char *buf, size_t buflen);
# endif
# endif
# define program_name getprogname ()
# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
# if GNULIB_defined_verror
# undef verror
# endif
# if GNULIB_defined_verror_at_line
# undef verror_at_line
# endif
#endif /* not _LIBC */
#if !_LIBC
/* Return non-zero if FD is open. */
static int
is_open (int fd)
{
# if defined _WIN32 && ! defined __CYGWIN__
/* On native Windows: The initial state of unassigned standard file
descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
There is no fcntl, and the gnulib replacement fcntl does not support
F_GETFL. */
return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
# else
# ifndef F_GETFL
# error Please port fcntl to your platform
# endif
return 0 <= fcntl (fd, F_GETFL);
# endif
}
#endif
static void
flush_stdout (void)
{
#if !_LIBC
int stdout_fd;
# if GNULIB_FREOPEN_SAFER
/* Use of gnulib's freopen-safer module normally ensures that
fileno (stdout) == 1
whenever stdout is open. */
stdout_fd = STDOUT_FILENO;
# else
/* POSIX states that fileno (stdout) after fclose is unspecified. But in
practice it is not a problem, because stdout is statically allocated and
the fd of a FILE stream is stored as a field in its allocated memory. */
stdout_fd = fileno (stdout);
# endif
/* POSIX states that fflush (stdout) after fclose is unspecified; it
is safe in glibc, but not on all other platforms. fflush (NULL)
is always defined, but too draconian. */
if (0 <= stdout_fd && is_open (stdout_fd))
#endif
fflush (stdout);
}
static void
print_errno_message (int errnum)
{
char const *s;
#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
char errbuf[1024];
# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
s = __strerror_r (errnum, errbuf, sizeof errbuf);
# else
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
s = errbuf;
else
s = 0;
# endif
#else
s = strerror (errnum);
#endif
#if !_LIBC
if (! s)
s = _("Unknown system error");
#endif
#if _LIBC
__fxprintf (NULL, ": %s", s);
#else
fprintf (stderr, ": %s", s);
#endif
}
static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))
error_tail (int status, int errnum, const char *message, va_list args,
unsigned int mode_flags)
{
#if _LIBC
int ret = __vfxprintf (stderr, message, args, mode_flags);
if (ret < 0 && errno == ENOMEM && _IO_fwide (stderr, 0) > 0)
/* Leave a trace in case the heap allocation of the message string
failed. */
fputws_unlocked (L"out of memory\n", stderr);
#else
vfprintf (stderr, message, args);
#endif
++error_message_count;
if (errnum)
print_errno_message (errnum);
#if _LIBC
__fxprintf (NULL, "\n");
#else
putc ('\n', stderr);
#endif
fflush (stderr);
if (status)
exit (status);
}
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
If ERRNUM is nonzero, print its corresponding system error message.
Exit with status STATUS if it is nonzero. */
void
__error_internal (int status, int errnum, const char *message,
va_list args, unsigned int mode_flags)
{
#if defined _LIBC
/* We do not want this call to be cut short by a thread
cancellation. Therefore disable cancellation for now. */
int state = PTHREAD_CANCEL_ENABLE;
__pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
#endif
flush_stdout ();
#ifdef _LIBC
_IO_flockfile (stderr);
#endif
if (error_print_progname)
(*error_print_progname) ();
else
{
#if _LIBC
__fxprintf (NULL, "%s: ", program_name);
#else
fprintf (stderr, "%s: ", program_name);
#endif
}
error_tail (status, errnum, message, args, mode_flags);
#ifdef _LIBC
_IO_funlockfile (stderr);
__pthread_setcancelstate (state, NULL);
#endif
}
void
error (int status, int errnum, const char *message, ...)
{
va_list ap;
va_start (ap, message);
__error_internal (status, errnum, message, ap, 0);
va_end (ap);
}
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
int error_one_per_line;
void
__error_at_line_internal (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message,
va_list args, unsigned int mode_flags)
{
if (error_one_per_line)
{
static const char *old_file_name;
static unsigned int old_line_number;
if (old_line_number == line_number
&& (file_name == old_file_name
|| (old_file_name != NULL
&& file_name != NULL
&& strcmp (old_file_name, file_name) == 0)))
/* Simply return and print nothing. */
return;
old_file_name = file_name;
old_line_number = line_number;
}
#if defined _LIBC
/* We do not want this call to be cut short by a thread
cancellation. Therefore disable cancellation for now. */
int state = PTHREAD_CANCEL_ENABLE;
__pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
#endif
flush_stdout ();
#ifdef _LIBC
_IO_flockfile (stderr);
#endif
if (error_print_progname)
(*error_print_progname) ();
else
{
#if _LIBC
__fxprintf (NULL, "%s:", program_name);
#else
fprintf (stderr, "%s:", program_name);
#endif
}
#if _LIBC
__fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
file_name, line_number);
#else
fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
file_name, line_number);
#endif
error_tail (status, errnum, message, args, mode_flags);
#ifdef _LIBC
_IO_funlockfile (stderr);
__pthread_setcancelstate (state, NULL);
#endif
}
void
error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message, ...)
{
va_list ap;
va_start (ap, message);
__error_at_line_internal (status, errnum, file_name, line_number,
message, ap, 0);
va_end (ap);
}
#ifdef _LIBC
/* Make the weak alias. */
# undef error
# undef error_at_line
weak_alias (__error, error)
weak_alias (__error_at_line, error_at_line)
#endif

View File

@@ -1,24 +0,0 @@
/* Failure exit status
Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "exitfail.h"
#include <stdlib.h>
int volatile exit_failure = EXIT_FAILURE;

View File

@@ -1,629 +0,0 @@
/* Provide file descriptor control.
Copyright (C) 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Eric Blake <ebb9@byu.net>. */
#include <config.h>
/* Specification. */
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef __KLIBC__
# define INCL_DOS
# include <os2.h>
#endif
#if defined _WIN32 && ! defined __CYGWIN__
/* Get declarations of the native Windows API functions. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
# if GNULIB_MSVC_NOTHROW
# include "msvc-nothrow.h"
# else
# include <io.h>
# endif
/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
# define OPEN_MAX_MAX 0x10000
/* Duplicate OLDFD into the first available slot of at least NEWFD,
which must be positive, with FLAGS determining whether the duplicate
will be inheritable. */
static int
dupfd (int oldfd, int newfd, int flags)
{
/* Mingw has no way to create an arbitrary fd. Iterate until all
file descriptors less than newfd are filled up. */
HANDLE curr_process = GetCurrentProcess ();
HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
unsigned int fds_to_close_bound = 0;
int result;
BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
int mode;
if (newfd < 0 || getdtablesize () <= newfd)
{
errno = EINVAL;
return -1;
}
if (old_handle == INVALID_HANDLE_VALUE
|| (mode = _setmode (oldfd, O_BINARY)) == -1)
{
/* oldfd is not open, or is an unassigned standard file
descriptor. */
errno = EBADF;
return -1;
}
_setmode (oldfd, mode);
flags |= mode;
for (;;)
{
HANDLE new_handle;
int duplicated_fd;
unsigned int index;
if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
old_handle, /* SourceHandle */
curr_process, /* TargetProcessHandle */
(PHANDLE) &new_handle, /* TargetHandle */
(DWORD) 0, /* DesiredAccess */
inherit, /* InheritHandle */
DUPLICATE_SAME_ACCESS)) /* Options */
{
switch (GetLastError ())
{
case ERROR_TOO_MANY_OPEN_FILES:
errno = EMFILE;
break;
case ERROR_INVALID_HANDLE:
case ERROR_INVALID_TARGET_HANDLE:
case ERROR_DIRECT_ACCESS_HANDLE:
errno = EBADF;
break;
case ERROR_INVALID_PARAMETER:
case ERROR_INVALID_FUNCTION:
case ERROR_INVALID_ACCESS:
errno = EINVAL;
break;
default:
errno = EACCES;
break;
}
result = -1;
break;
}
duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
if (duplicated_fd < 0)
{
CloseHandle (new_handle);
result = -1;
break;
}
if (newfd <= duplicated_fd)
{
result = duplicated_fd;
break;
}
/* Set the bit duplicated_fd in fds_to_close[]. */
index = (unsigned int) duplicated_fd / CHAR_BIT;
if (fds_to_close_bound <= index)
{
if (sizeof fds_to_close <= index)
/* Need to increase OPEN_MAX_MAX. */
abort ();
memset (fds_to_close + fds_to_close_bound, '\0',
index + 1 - fds_to_close_bound);
fds_to_close_bound = index + 1;
}
fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
}
/* Close the previous fds that turned out to be too small. */
{
int saved_errno = errno;
unsigned int duplicated_fd;
for (duplicated_fd = 0;
duplicated_fd < fds_to_close_bound * CHAR_BIT;
duplicated_fd++)
if ((fds_to_close[duplicated_fd / CHAR_BIT]
>> (duplicated_fd % CHAR_BIT))
& 1)
close (duplicated_fd);
errno = saved_errno;
}
# if REPLACE_FCHDIR
if (0 <= result)
result = _gl_register_dup (oldfd, result);
# endif
return result;
}
#endif /* W32 */
/* Forward declarations, because we '#undef fcntl' in the middle of this
compilation unit. */
/* Our implementation of fcntl (fd, F_DUPFD, target). */
static int rpl_fcntl_DUPFD (int fd, int target);
/* Our implementation of fcntl (fd, F_DUPFD_CLOEXEC, target). */
static int rpl_fcntl_DUPFD_CLOEXEC (int fd, int target);
#ifdef __KLIBC__
/* Adds support for fcntl on directories. */
static int klibc_fcntl (int fd, int action, /* arg */...);
#endif
/* Perform the specified ACTION on the file descriptor FD, possibly
using the argument ARG further described below. This replacement
handles the following actions, and forwards all others on to the
native fcntl. An unrecognized ACTION returns -1 with errno set to
EINVAL.
F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
If successful, return the duplicate, which will be inheritable;
otherwise return -1 and set errno.
F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
target fd. If successful, return the duplicate, which will not be
inheritable; otherwise return -1 and set errno.
F_GETFD - ARG need not be present. If successful, return a
non-negative value containing the descriptor flags of FD (only
FD_CLOEXEC is portable, but other flags may be present); otherwise
return -1 and set errno. */
int
fcntl (int fd, int action, /* arg */...)
#undef fcntl
#ifdef __KLIBC__
# define fcntl klibc_fcntl
#endif
{
va_list arg;
int result = -1;
va_start (arg, action);
switch (action)
{
case F_DUPFD:
{
int target = va_arg (arg, int);
result = rpl_fcntl_DUPFD (fd, target);
break;
}
case F_DUPFD_CLOEXEC:
{
int target = va_arg (arg, int);
result = rpl_fcntl_DUPFD_CLOEXEC (fd, target);
break;
}
#if !HAVE_FCNTL
case F_GETFD:
{
# if defined _WIN32 && ! defined __CYGWIN__
HANDLE handle = (HANDLE) _get_osfhandle (fd);
DWORD flags;
if (handle == INVALID_HANDLE_VALUE
|| GetHandleInformation (handle, &flags) == 0)
errno = EBADF;
else
result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
# else /* !W32 */
/* Use dup2 to reject invalid file descriptors. No way to
access this information, so punt. */
if (0 <= dup2 (fd, fd))
result = 0;
# endif /* !W32 */
break;
} /* F_GETFD */
#endif /* !HAVE_FCNTL */
/* Implementing F_SETFD on mingw is not trivial - there is no
API for changing the O_NOINHERIT bit on an fd, and merely
changing the HANDLE_FLAG_INHERIT bit on the underlying handle
can lead to odd state. It may be possible by duplicating the
handle, using _open_osfhandle with the right flags, then
using dup2 to move the duplicate onto the original, but that
is not supported for now. */
default:
{
#if HAVE_FCNTL
switch (action)
{
#ifdef F_BARRIERFSYNC /* macOS */
case F_BARRIERFSYNC:
#endif
#ifdef F_CHKCLEAN /* macOS */
case F_CHKCLEAN:
#endif
#ifdef F_CLOSEM /* NetBSD, HP-UX */
case F_CLOSEM:
#endif
#ifdef F_FLUSH_DATA /* macOS */
case F_FLUSH_DATA:
#endif
#ifdef F_FREEZE_FS /* macOS */
case F_FREEZE_FS:
#endif
#ifdef F_FULLFSYNC /* macOS */
case F_FULLFSYNC:
#endif
#ifdef F_GETCONFINED /* macOS */
case F_GETCONFINED:
#endif
#ifdef F_GETDEFAULTPROTLEVEL /* macOS */
case F_GETDEFAULTPROTLEVEL:
#endif
#ifdef F_GETFD /* POSIX */
case F_GETFD:
#endif
#ifdef F_GETFL /* POSIX */
case F_GETFL:
#endif
#ifdef F_GETLEASE /* Linux */
case F_GETLEASE:
#endif
#ifdef F_GETNOSIGPIPE /* macOS */
case F_GETNOSIGPIPE:
#endif
#ifdef F_GETOWN /* POSIX */
case F_GETOWN:
#endif
#ifdef F_GETPIPE_SZ /* Linux */
case F_GETPIPE_SZ:
#endif
#ifdef F_GETPROTECTIONCLASS /* macOS */
case F_GETPROTECTIONCLASS:
#endif
#ifdef F_GETPROTECTIONLEVEL /* macOS */
case F_GETPROTECTIONLEVEL:
#endif
#ifdef F_GET_SEALS /* Linux */
case F_GET_SEALS:
#endif
#ifdef F_GETSIG /* Linux */
case F_GETSIG:
#endif
#ifdef F_MAXFD /* NetBSD */
case F_MAXFD:
#endif
#ifdef F_RECYCLE /* macOS */
case F_RECYCLE:
#endif
#ifdef F_SETFIFOENH /* HP-UX */
case F_SETFIFOENH:
#endif
#ifdef F_THAW_FS /* macOS */
case F_THAW_FS:
#endif
/* These actions take no argument. */
result = fcntl (fd, action);
break;
#ifdef F_ADD_SEALS /* Linux */
case F_ADD_SEALS:
#endif
#ifdef F_BADFD /* Solaris */
case F_BADFD:
#endif
#ifdef F_CHECK_OPENEVT /* macOS */
case F_CHECK_OPENEVT:
#endif
#ifdef F_DUP2FD /* FreeBSD, AIX, Solaris */
case F_DUP2FD:
#endif
#ifdef F_DUP2FD_CLOEXEC /* FreeBSD, Solaris */
case F_DUP2FD_CLOEXEC:
#endif
#ifdef F_DUP2FD_CLOFORK /* Solaris */
case F_DUP2FD_CLOFORK:
#endif
#ifdef F_DUPFD /* POSIX */
case F_DUPFD:
#endif
#ifdef F_DUPFD_CLOEXEC /* POSIX */
case F_DUPFD_CLOEXEC:
#endif
#ifdef F_DUPFD_CLOFORK /* Solaris */
case F_DUPFD_CLOFORK:
#endif
#ifdef F_GETXFL /* Solaris */
case F_GETXFL:
#endif
#ifdef F_GLOBAL_NOCACHE /* macOS */
case F_GLOBAL_NOCACHE:
#endif
#ifdef F_MAKECOMPRESSED /* macOS */
case F_MAKECOMPRESSED:
#endif
#ifdef F_MOVEDATAEXTENTS /* macOS */
case F_MOVEDATAEXTENTS:
#endif
#ifdef F_NOCACHE /* macOS */
case F_NOCACHE:
#endif
#ifdef F_NODIRECT /* macOS */
case F_NODIRECT:
#endif
#ifdef F_NOTIFY /* Linux */
case F_NOTIFY:
#endif
#ifdef F_OPLKACK /* IRIX */
case F_OPLKACK:
#endif
#ifdef F_OPLKREG /* IRIX */
case F_OPLKREG:
#endif
#ifdef F_RDAHEAD /* macOS */
case F_RDAHEAD:
#endif
#ifdef F_SETBACKINGSTORE /* macOS */
case F_SETBACKINGSTORE:
#endif
#ifdef F_SETCONFINED /* macOS */
case F_SETCONFINED:
#endif
#ifdef F_SETFD /* POSIX */
case F_SETFD:
#endif
#ifdef F_SETFL /* POSIX */
case F_SETFL:
#endif
#ifdef F_SETLEASE /* Linux */
case F_SETLEASE:
#endif
#ifdef F_SETNOSIGPIPE /* macOS */
case F_SETNOSIGPIPE:
#endif
#ifdef F_SETOWN /* POSIX */
case F_SETOWN:
#endif
#ifdef F_SETPIPE_SZ /* Linux */
case F_SETPIPE_SZ:
#endif
#ifdef F_SETPROTECTIONCLASS /* macOS */
case F_SETPROTECTIONCLASS:
#endif
#ifdef F_SETSIG /* Linux */
case F_SETSIG:
#endif
#ifdef F_SINGLE_WRITER /* macOS */
case F_SINGLE_WRITER:
#endif
/* These actions take an 'int' argument. */
{
int x = va_arg (arg, int);
result = fcntl (fd, action, x);
}
break;
default:
/* Other actions take a pointer argument. */
{
void *p = va_arg (arg, void *);
result = fcntl (fd, action, p);
}
break;
}
#else
errno = EINVAL;
#endif
break;
}
}
va_end (arg);
return result;
}
static int
rpl_fcntl_DUPFD (int fd, int target)
{
int result;
#if !HAVE_FCNTL
result = dupfd (fd, target, 0);
#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
/* Detect invalid target; needed for cygwin 1.5.x. */
if (target < 0 || getdtablesize () <= target)
{
result = -1;
errno = EINVAL;
}
else
{
/* Haiku alpha 2 loses fd flags on original. */
int flags = fcntl (fd, F_GETFD);
if (flags < 0)
result = -1;
else
{
result = fcntl (fd, F_DUPFD, target);
if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
{
int saved_errno = errno;
close (result);
result = -1;
errno = saved_errno;
}
# if REPLACE_FCHDIR
if (0 <= result)
result = _gl_register_dup (fd, result);
# endif
}
}
#else
result = fcntl (fd, F_DUPFD, target);
#endif
return result;
}
static int
rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
{
int result;
#if !HAVE_FCNTL
result = dupfd (fd, target, O_CLOEXEC);
#else /* HAVE_FCNTL */
# if defined __NetBSD__ || defined __HAIKU__
/* On NetBSD 9.0, the system fcntl (fd, F_DUPFD_CLOEXEC, target)
has only the same effect as fcntl (fd, F_DUPFD, target). */
/* On Haiku, the system fcntl (fd, F_DUPFD_CLOEXEC, target) sets
the FD_CLOEXEC flag on fd, not on target. Therefore avoid the
system fcntl in this case. */
# define have_dupfd_cloexec -1
# else
/* Try the system call first, if the headers claim it exists
(that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
may be running with a glibc that has the macro but with an
older kernel that does not support it. Cache the
information on whether the system call really works, but
avoid caching failure if the corresponding F_DUPFD fails
for any reason. 0 = unknown, 1 = yes, -1 = no. */
static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
if (0 <= have_dupfd_cloexec)
{
result = fcntl (fd, F_DUPFD_CLOEXEC, target);
if (0 <= result || errno != EINVAL)
{
have_dupfd_cloexec = 1;
# if REPLACE_FCHDIR
if (0 <= result)
result = _gl_register_dup (fd, result);
# endif
}
else
{
result = rpl_fcntl_DUPFD (fd, target);
if (result >= 0)
have_dupfd_cloexec = -1;
}
}
else
# endif
result = rpl_fcntl_DUPFD (fd, target);
if (0 <= result && have_dupfd_cloexec == -1)
{
int flags = fcntl (result, F_GETFD);
if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
{
int saved_errno = errno;
close (result);
errno = saved_errno;
result = -1;
}
}
#endif /* HAVE_FCNTL */
return result;
}
#undef fcntl
#ifdef __KLIBC__
static int
klibc_fcntl (int fd, int action, /* arg */...)
{
va_list arg_ptr;
int arg;
struct stat sbuf;
int result;
va_start (arg_ptr, action);
arg = va_arg (arg_ptr, int);
result = fcntl (fd, action, arg);
/* EPERM for F_DUPFD, ENOTSUP for others */
if (result == -1 && (errno == EPERM || errno == ENOTSUP)
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
{
ULONG ulMode;
switch (action)
{
case F_DUPFD:
/* Find available fd */
while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
arg++;
result = dup2 (fd, arg);
break;
/* Using underlying APIs is right ? */
case F_GETFD:
if (DosQueryFHState (fd, &ulMode))
break;
result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
break;
case F_SETFD:
if (arg & ~FD_CLOEXEC)
break;
if (DosQueryFHState (fd, &ulMode))
break;
if (arg & FD_CLOEXEC)
ulMode |= OPEN_FLAGS_NOINHERIT;
else
ulMode &= ~OPEN_FLAGS_NOINHERIT;
/* Filter supported flags. */
ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
| OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
if (DosSetFHState (fd, ulMode))
break;
result = 0;
break;
case F_GETFL:
result = 0;
break;
case F_SETFL:
if (arg != 0)
break;
result = 0;
break;
default:
errno = EINVAL;
break;
}
}
va_end (arg_ptr);
return result;
}
#endif

View File

@@ -1,53 +0,0 @@
/* Make free() preserve errno.
Copyright (C) 2003, 2006, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Paul Eggert */
#include <config.h>
/* Specification. */
#include <stdlib.h>
/* A function definition is only needed if HAVE_FREE_POSIX is not defined. */
#if !HAVE_FREE_POSIX
# include <errno.h>
void
rpl_free (void *p)
# undef free
{
# if defined __GNUC__ && !defined __clang__
/* An invalid GCC optimization
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396>
would optimize away the assignments in the code below, when link-time
optimization (LTO) is enabled. Make the code more complicated, so that
GCC does not grok how to optimize it. */
int err[2];
err[0] = errno;
err[1] = errno;
errno = 0;
free (p);
errno = err[errno == 0];
# else
int err = errno;
free (p);
errno = err;
# endif
}
#endif

View File

@@ -1,124 +0,0 @@
/* getdtablesize() function: Return maximum possible file descriptor value + 1.
Copyright (C) 2008-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
#if defined _WIN32 && ! defined __CYGWIN__
# include <stdio.h>
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
# include "msvc-inval.h"
# endif
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
_setmaxstdio_nothrow (int newmax)
{
int result;
TRY_MSVC_INVAL
{
result = _setmaxstdio (newmax);
}
CATCH_MSVC_INVAL
{
result = -1;
}
DONE_MSVC_INVAL;
return result;
}
# else
# define _setmaxstdio_nothrow _setmaxstdio
# endif
/* Cache for the previous getdtablesize () result. Safe to cache because
Windows also lacks setrlimit. */
static int dtablesize;
int
getdtablesize (void)
{
if (dtablesize == 0)
{
/* We are looking for the number N such that the valid file descriptors
are 0..N-1. It can be obtained through a loop as follows:
{
int fd;
for (fd = 3; fd < 65536; fd++)
if (dup2 (0, fd) == -1)
break;
return fd;
}
On Windows XP, the result is 2048.
The drawback of this loop is that it allocates memory for a libc
internal array that is never freed.
The number N can also be obtained as the upper bound for
_getmaxstdio (). _getmaxstdio () returns the maximum number of open
FILE objects. The sanity check in _setmaxstdio reveals the maximum
number of file descriptors. This too allocates memory, but it is
freed when we call _setmaxstdio with the original value. */
int orig_max_stdio = _getmaxstdio ();
unsigned int bound;
for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
;
_setmaxstdio_nothrow (orig_max_stdio);
dtablesize = bound;
}
return dtablesize;
}
#else
# include <limits.h>
# include <sys/resource.h>
# ifndef RLIM_SAVED_CUR
# define RLIM_SAVED_CUR RLIM_INFINITY
# endif
# ifndef RLIM_SAVED_MAX
# define RLIM_SAVED_MAX RLIM_INFINITY
# endif
# ifdef __CYGWIN__
/* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it
hits the compile-time constant hard limit of 3200. We might as
well just report the hard limit. */
# define rlim_cur rlim_max
# endif
int
getdtablesize (void)
{
struct rlimit lim;
if (getrlimit (RLIMIT_NOFILE, &lim) == 0
&& 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX
&& lim.rlim_cur != RLIM_INFINITY
&& lim.rlim_cur != RLIM_SAVED_CUR
&& lim.rlim_cur != RLIM_SAVED_MAX)
return lim.rlim_cur;
return INT_MAX;
}
#endif

View File

@@ -1,47 +0,0 @@
/* hard-locale.c -- Determine whether a locale is hard.
Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2024 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "hard-locale.h"
#include <locale.h>
#include <stdlib.h>
#include <string.h>
bool
hard_locale (int category)
{
char locale[SETLOCALE_NULL_MAX];
if (setlocale_null_r (category, locale, sizeof (locale)))
return false;
if (!(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0))
return true;
#if defined __ANDROID__
/* On Android 5.0 or newer, it is possible to set a locale that has the same
name as the "C" locale but in fact uses UTF-8 encoding. Cf. test case 2 in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-01/msg00141.html>. */
if (MB_CUR_MAX > 1)
return true;
#endif
return false;
}

View File

@@ -1,21 +0,0 @@
/* malloc with idx_t rather than size_t
Copyright 2021-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#define IALLOC_INLINE _GL_EXTERN_INLINE
#include "ialloc.h"

View File

@@ -1,36 +0,0 @@
/* Test whether a wide character has a given property.
Copyright (C) 2011-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wctype.h>
#if GNULIB_defined_wint_t && !GNULIB_defined_wctype_t
int
iswctype (wint_t wc, wctype_t desc)
# undef iswctype
{
return ((wchar_t) wc == wc ? iswctype ((wchar_t) wc, desc) : 0);
}
#else
# include "iswctype-impl.h"
#endif

View File

@@ -1,26 +0,0 @@
/* Test wide character for being a digit.
Copyright (C) 2020-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wctype.h>
int
iswdigit (wint_t wc)
{
return wc >= '0' && wc <= '9';
}

View File

@@ -1,33 +0,0 @@
/* Test wide character for being a punctuation or symbol character.
Copyright (C) 2023-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wctype.h>
#include <ctype.h>
int
iswpunct (wint_t wc)
#undef iswpunct
{
#if defined __ANDROID__
if ((unsigned int) wc < 128)
return ispunct ((unsigned int) wc);
#endif
return iswpunct (wc);
}

View File

@@ -1,33 +0,0 @@
/* Test wide character for being a hexadecimal digit.
Copyright (C) 2020-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wctype.h>
int
iswxdigit (wint_t wc)
{
return ((wc >= '0' && wc <= '9')
#if 'A' == 0x41 && 'a' == 0x61
/* Optimization, assuming ASCII */
|| ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')
#else
|| (wc >= 'A' && wc <= 'F') || (wc >= 'a' && wc <= 'f')
#endif
);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,139 +0,0 @@
/* Utility to accept --help and --version options as unobtrusively as possible.
Copyright (C) 1993-1994, 1998-2000, 2002-2006, 2009-2024 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
#include <config.h>
/* Specification. */
#include "long-options.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include "version-etc.h"
#include "exitfail.h"
static struct option const long_options[] =
{
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
/* Process long options --help and --version, but only if argc == 2.
Be careful not to gobble up "--". */
void
parse_long_options (int argc,
char **argv,
const char *command_name,
const char *package,
const char *version,
void (*usage_func) (int),
/* const char *author1, ...*/ ...)
{
int c;
int saved_opterr;
saved_opterr = opterr;
/* Don't print an error message for unrecognized options. */
opterr = 0;
if (argc == 2
&& (c = getopt_long (argc, argv, "+", long_options, NULL)) != -1)
{
switch (c)
{
case 'h':
(*usage_func) (EXIT_SUCCESS);
break;
case 'v':
{
va_list authors;
va_start (authors, usage_func);
version_etc_va (stdout, command_name, package, version, authors);
exit (EXIT_SUCCESS);
}
default:
/* Don't process any other long-named options. */
break;
}
}
/* Restore previous value. */
opterr = saved_opterr;
/* Reset this to zero so that getopt internals get initialized from
the probably-new parameters when/if getopt is called later. */
optind = 0;
}
/* Process the GNU default long options --help and --version (see also
https://gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html),
and fail for any other unknown long or short option.
Use with SCAN_ALL=true to scan until "--", or with SCAN_ALL=false to stop
at the first non-option argument (or "--", whichever comes first). */
void
parse_gnu_standard_options_only (int argc,
char **argv,
const char *command_name,
const char *package,
const char *version,
bool scan_all,
void (*usage_func) (int),
/* const char *author1, ...*/ ...)
{
int c;
int saved_opterr = opterr;
/* Print an error message for unrecognized options. */
opterr = 1;
const char *optstring = scan_all ? "" : "+";
if ((c = getopt_long (argc, argv, optstring, long_options, NULL)) != -1)
{
switch (c)
{
case 'h':
(*usage_func) (EXIT_SUCCESS);
break;
case 'v':
{
va_list authors;
va_start (authors, usage_func);
version_etc_va (stdout, command_name, package, version, authors);
exit (EXIT_SUCCESS);
}
default:
(*usage_func) (exit_failure);
break;
}
}
/* Restore previous value. */
opterr = saved_opterr;
}

View File

@@ -1,528 +0,0 @@
/* Type-safe arrays which grow dynamically.
Copyright (C) 2017-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* Pre-processor macros which act as parameters:
DYNARRAY_STRUCT
The struct tag of dynamic array to be defined.
DYNARRAY_ELEMENT
The type name of the element type. Elements are copied
as if by memcpy, and can change address as the dynamic
array grows.
DYNARRAY_PREFIX
The prefix of the functions which are defined.
The following parameters are optional:
DYNARRAY_ELEMENT_FREE
DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
contents of elements. E is of type DYNARRAY_ELEMENT *.
DYNARRAY_ELEMENT_INIT
DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
element. E is of type DYNARRAY_ELEMENT *.
If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
defined, new elements are automatically zero-initialized.
Otherwise, new elements have undefined contents.
DYNARRAY_INITIAL_SIZE
The size of the statically allocated array (default:
at least 2, more elements if they fit into 128 bytes).
Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
there is no statically allocated array at, and all non-empty
arrays are heap-allocated.
DYNARRAY_FINAL_TYPE
The name of the type which holds the final array. If not
defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
must be a struct type, with members of type DYNARRAY_ELEMENT and
size_t at the start (in this order).
These macros are undefined after this header file has been
included.
The following types are provided (their members are private to the
dynarray implementation):
struct DYNARRAY_STRUCT
The following functions are provided:
void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *);
bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *);
size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t);
void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *);
bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t);
void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *);
The following functions are provided are provided if the
prerequisites are met:
bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
DYNARRAY_FINAL_TYPE *);
(if DYNARRAY_FINAL_TYPE is defined)
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
size_t *);
(if DYNARRAY_FINAL_TYPE is not defined)
*/
#include <malloc/dynarray.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#ifndef DYNARRAY_STRUCT
# error "DYNARRAY_STRUCT must be defined"
#endif
#ifndef DYNARRAY_ELEMENT
# error "DYNARRAY_ELEMENT must be defined"
#endif
#ifndef DYNARRAY_PREFIX
# error "DYNARRAY_PREFIX must be defined"
#endif
#ifdef DYNARRAY_INITIAL_SIZE
# if DYNARRAY_INITIAL_SIZE < 0
# error "DYNARRAY_INITIAL_SIZE must be non-negative"
# endif
# if DYNARRAY_INITIAL_SIZE > 0
# define DYNARRAY_HAVE_SCRATCH 1
# else
# define DYNARRAY_HAVE_SCRATCH 0
# endif
#else
/* Provide a reasonable default which limits the size of
DYNARRAY_STRUCT. */
# define DYNARRAY_INITIAL_SIZE \
(sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT))
# define DYNARRAY_HAVE_SCRATCH 1
#endif
/* Public type definitions. */
/* All fields of this struct are private to the implementation. */
struct DYNARRAY_STRUCT
{
union
{
struct dynarray_header dynarray_abstract;
struct
{
/* These fields must match struct dynarray_header. */
size_t used;
size_t allocated;
DYNARRAY_ELEMENT *array;
} dynarray_header;
} u;
#if DYNARRAY_HAVE_SCRATCH
/* Initial inline allocation. */
DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE];
#endif
};
/* Internal use only: Helper macros. */
/* Ensure macro-expansion of DYNARRAY_PREFIX. */
#define DYNARRAY_CONCAT0(prefix, name) prefix##name
#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
so that Gnulib does not change 'free' to 'rpl_free'. */
#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
/* Address of the scratch buffer if any. */
#if DYNARRAY_HAVE_SCRATCH
# define DYNARRAY_SCRATCH(list) (list)->scratch
#else
# define DYNARRAY_SCRATCH(list) NULL
#endif
/* Internal use only: Helper functions. */
/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array
elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE
macro expansion. */
static inline void
DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
size_t __dynarray_used)
{
#ifdef DYNARRAY_ELEMENT_FREE
for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i)
DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]);
#endif /* DYNARRAY_ELEMENT_FREE */
}
/* Internal function. Free the non-scratch array allocation. */
static inline void
DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
{
#if DYNARRAY_HAVE_SCRATCH
if (list->u.dynarray_header.array != list->scratch)
free (list->u.dynarray_header.array);
#else
free (list->u.dynarray_header.array);
#endif
}
/* Public functions. */
/* Initialize a dynamic array object. This must be called before any
use of the object. */
__attribute_nonnull__ ((1))
static void
DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
{
list->u.dynarray_header.used = 0;
list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE;
list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
}
/* Deallocate the dynamic array and its elements. */
__attribute_maybe_unused__ __attribute_nonnull__ ((1))
static void
DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
DYNARRAY_NAME (free__array__) (list);
DYNARRAY_NAME (init) (list);
}
/* Return true if the dynamic array is in an error state. */
__attribute_nonnull__ ((1))
static inline bool
DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.allocated == __dynarray_error_marker ();
}
/* Mark the dynamic array as failed. All elements are deallocated as
a side effect. */
__attribute_nonnull__ ((1))
static void
DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
DYNARRAY_NAME (free__array__) (list);
list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
list->u.dynarray_header.used = 0;
list->u.dynarray_header.allocated = __dynarray_error_marker ();
}
/* Return the number of elements which have been added to the dynamic
array. */
__attribute_nonnull__ ((1))
static inline size_t
DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.used;
}
/* Return a pointer to the array element at INDEX. Terminate the
process if INDEX is out of bounds. */
__attribute_nonnull__ ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
{
if (__glibc_unlikely (index >= DYNARRAY_NAME (size) (list)))
__libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index);
return list->u.dynarray_header.array + index;
}
/* Return a pointer to the first array element, if any. For a
zero-length array, the pointer can be NULL even though the dynamic
array has not entered the failure state. */
__attribute_nonnull__ ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.array;
}
/* Return a pointer one element past the last array element. For a
zero-length array, the pointer can be NULL even though the dynamic
array has not entered the failure state. */
__attribute_nonnull__ ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.array + list->u.dynarray_header.used;
}
/* Internal function. Slow path for the add function below. */
static void
DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
{
if (__glibc_unlikely
(!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT))))
{
DYNARRAY_NAME (mark_failed) (list);
return;
}
/* Copy the new element and increase the array length. */
list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
}
/* Add ITEM at the end of the array, enlarging it by one element.
Mark *LIST as failed if the dynamic array allocation size cannot be
increased. */
__attribute_nonnull__ ((1))
static inline void
DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
{
/* Do nothing in case of previous error. */
if (DYNARRAY_NAME (has_failed) (list))
return;
/* Enlarge the array if necessary. */
if (__glibc_unlikely (list->u.dynarray_header.used
== list->u.dynarray_header.allocated))
{
DYNARRAY_NAME (add__) (list, item);
return;
}
/* Copy the new element and increase the array length. */
list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
}
/* Internal function. Building block for the emplace functions below.
Assumes space for one more element in *LIST. */
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_ELEMENT *result
= &list->u.dynarray_header.array[list->u.dynarray_header.used];
++list->u.dynarray_header.used;
#if defined (DYNARRAY_ELEMENT_INIT)
DYNARRAY_ELEMENT_INIT (result);
#elif defined (DYNARRAY_ELEMENT_FREE)
memset (result, 0, sizeof (*result));
#endif
return result;
}
/* Internal function. Slow path for the emplace function below. */
static DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
{
if (__glibc_unlikely
(!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT))))
{
DYNARRAY_NAME (mark_failed) (list);
return NULL;
}
return DYNARRAY_NAME (emplace__tail__) (list);
}
/* Allocate a place for a new element in *LIST and return a pointer to
it. The pointer can be NULL if the dynamic array cannot be
enlarged due to a memory allocation failure. */
__attribute_maybe_unused__ __attribute_warn_unused_result__
__attribute_nonnull__ ((1))
static
/* Avoid inlining with the larger initialization code. */
#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
inline
#endif
DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
{
/* Do nothing in case of previous error. */
if (DYNARRAY_NAME (has_failed) (list))
return NULL;
/* Enlarge the array if necessary. */
if (__glibc_unlikely (list->u.dynarray_header.used
== list->u.dynarray_header.allocated))
return (DYNARRAY_NAME (emplace__) (list));
return DYNARRAY_NAME (emplace__tail__) (list);
}
/* Change the size of *LIST to SIZE. If SIZE is larger than the
existing size, new elements are added (which can be initialized).
Otherwise, the list is truncated, and elements are freed. Return
false on memory allocation failure (and mark *LIST as failed). */
__attribute_maybe_unused__ __attribute_nonnull__ ((1))
static bool
DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
{
if (size > list->u.dynarray_header.used)
{
bool ok;
#if defined (DYNARRAY_ELEMENT_INIT)
/* The new elements have to be initialized. */
size_t old_size = list->u.dynarray_header.used;
ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
size, DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT));
if (ok)
for (size_t i = old_size; i < size; ++i)
{
DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
}
#elif defined (DYNARRAY_ELEMENT_FREE)
/* Zero initialization is needed so that the elements can be
safely freed. */
ok = __libc_dynarray_resize_clear
(&list->u.dynarray_abstract, size,
DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT));
#else
ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
size, DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT));
#endif
if (__glibc_unlikely (!ok))
DYNARRAY_NAME (mark_failed) (list);
return ok;
}
else
{
/* The list has shrunk in size. Free the removed elements. */
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array + size,
list->u.dynarray_header.used - size);
list->u.dynarray_header.used = size;
return true;
}
}
/* Remove the last element of LIST if it is present. */
__attribute_maybe_unused__ __attribute_nonnull__ ((1))
static void
DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
{
/* used > 0 implies that the array is the non-failed state. */
if (list->u.dynarray_header.used > 0)
{
size_t new_length = list->u.dynarray_header.used - 1;
#ifdef DYNARRAY_ELEMENT_FREE
DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]);
#endif
list->u.dynarray_header.used = new_length;
}
}
/* Remove all elements from the list. The elements are freed, but the
list itself is not. */
__attribute_maybe_unused__ __attribute_nonnull__ ((1))
static void
DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
{
/* free__elements__ does nothing if the list is in the failed
state. */
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
list->u.dynarray_header.used = 0;
}
#ifdef DYNARRAY_FINAL_TYPE
/* Transfer the dynamic array to a permanent location at *RESULT.
Returns true on success on false on allocation failure. In either
case, *LIST is re-initialized and can be reused. A NULL pointer is
stored in *RESULT if LIST refers to an empty list. On success, the
pointer in *RESULT is heap-allocated and must be deallocated using
free. */
__attribute_maybe_unused__ __attribute_warn_unused_result__
__attribute_nonnull__ ((1, 2))
static bool
DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
DYNARRAY_FINAL_TYPE *result)
{
struct dynarray_finalize_result res;
if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT), &res))
{
/* On success, the result owns all the data. */
DYNARRAY_NAME (init) (list);
*result = (DYNARRAY_FINAL_TYPE) { res.array, res.length };
return true;
}
else
{
/* On error, we need to free all data. */
DYNARRAY_FREE (list);
errno = ENOMEM;
return false;
}
}
#else /* !DYNARRAY_FINAL_TYPE */
/* Transfer the dynamic array to a heap-allocated array and return a
pointer to it. The pointer is NULL if memory allocation fails, or
if the array is empty, so this function should be used only for
arrays which are known not be empty (usually because they always
have a sentinel at the end). If LENGTHP is not NULL, the array
length is written to *LENGTHP. *LIST is re-initialized and can be
reused. */
__attribute_maybe_unused__ __attribute_warn_unused_result__
__attribute_nonnull__ ((1))
static DYNARRAY_ELEMENT *
DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
{
struct dynarray_finalize_result res;
if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT), &res))
{
/* On success, the result owns all the data. */
DYNARRAY_NAME (init) (list);
if (lengthp != NULL)
*lengthp = res.length;
return res.array;
}
else
{
/* On error, we need to free all data. */
DYNARRAY_FREE (list);
errno = ENOMEM;
return NULL;
}
}
#endif /* !DYNARRAY_FINAL_TYPE */
/* Undo macro definitions. */
#undef DYNARRAY_CONCAT0
#undef DYNARRAY_CONCAT1
#undef DYNARRAY_NAME
#undef DYNARRAY_SCRATCH
#undef DYNARRAY_HAVE_SCRATCH
#undef DYNARRAY_STRUCT
#undef DYNARRAY_ELEMENT
#undef DYNARRAY_PREFIX
#undef DYNARRAY_ELEMENT_FREE
#undef DYNARRAY_ELEMENT_INIT
#undef DYNARRAY_INITIAL_SIZE
#undef DYNARRAY_FINAL_TYPE

View File

@@ -1,135 +0,0 @@
/* Safe automatic memory allocation.
Copyright (C) 2003, 2006-2007, 2009-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#define _GL_USE_STDLIB_ALLOC 1
#include <config.h>
/* Specification. */
#include "malloca.h"
#include <stdckdint.h>
#if defined __CHERI_PURE_CAPABILITY__
# include <cheri.h>
#endif
#include "idx.h"
/* The speed critical point in this file is freea() applied to an alloca()
result: it must be fast, to match the speed of alloca(). The speed of
mmalloca() and freea() in the other case are not critical, because they
are only invoked for big memory sizes.
Here we use a bit in the address as an indicator, an idea by Ondřej Bílka.
malloca() can return three types of pointers:
- Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation.
- Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap
allocation.
- NULL comes from a failed heap allocation. */
#if defined __CHERI_PURE_CAPABILITY__
/* Type for holding the original malloc() result. */
typedef uintptr_t small_t;
#else
/* Type for holding very small pointer differences. */
typedef unsigned char small_t;
/* Verify that it is wide enough. */
static_assert (2 * sa_alignment_max - 1 <= (small_t) -1);
#endif
void *
mmalloca (size_t n)
{
#if HAVE_ALLOCA
/* Allocate one more word, used to determine the address to pass to freea(),
and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */
uintptr_t alignment2_mask = 2 * sa_alignment_max - 1;
int plus = sizeof (small_t) + alignment2_mask;
idx_t nplus;
if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))
{
char *mem = (char *) malloc (nplus);
if (mem != NULL)
{
uintptr_t umem = (uintptr_t) mem;
/* The ckd_add avoids signed integer overflow on
theoretical platforms where UINTPTR_MAX <= INT_MAX. */
uintptr_t umemplus;
ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max)
+ sa_alignment_max - umem);
void *p = mem + offset;
/* Here p >= mem + sizeof (small_t),
and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
hence p + n <= mem + nplus.
So, the memory range [p, p+n) lies in the allocated memory range
[mem, mem + nplus). */
small_t *sp = p;
# if defined __CHERI_PURE_CAPABILITY__
sp[-1] = umem;
p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t),
sizeof (small_t) + n)
+ sizeof (small_t);
# else
sp[-1] = offset;
# endif
/* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
return p;
}
}
/* Out of memory. */
return NULL;
#else
# if !MALLOC_0_IS_NONNULL
if (n == 0)
n = 1;
# endif
return malloc (n);
#endif
}
#if HAVE_ALLOCA
void
freea (void *p)
{
/* Check argument. */
uintptr_t u = (uintptr_t) p;
if (u & (sa_alignment_max - 1))
{
/* p was not the result of a malloca() call. Invalid argument. */
abort ();
}
/* Determine whether p was a non-NULL pointer returned by mmalloca(). */
if (u & sa_alignment_max)
{
char *cp = p;
small_t *sp = p;
# if defined __CHERI_PURE_CAPABILITY__
void *mem = sp[-1];
# else
void *mem = cp - sp[-1];
# endif
free (mem);
}
}
#endif
/*
* Hey Emacs!
* Local Variables:
* coding: utf-8
* End:
*/

View File

@@ -1,288 +0,0 @@
/* Convert multibyte character to 32-bit wide character.
Copyright (C) 2020-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2020. */
#include <config.h>
/* Specification. */
#include <uchar.h>
#include "attribute.h"
#include <errno.h>
#include <stdlib.h>
#if GL_CHAR32_T_IS_UNICODE
# include "lc-charset-unicode.h"
#endif
#if GNULIB_defined_mbstate_t /* AIX, IRIX */
/* Implement mbrtoc32() on top of mbtowc() for the non-UTF-8 locales
and directly for the UTF-8 locales. */
/* Note: On AIX (64-bit) we can implement mbrtoc32 in two equivalent ways:
- in a way that parallels the override of mbrtowc; this is the code branch
here;
- in a way that invokes the overridden mbrtowc; this would be the #else
branch below.
They are equivalent. */
# if AVOID_ANY_THREADS
/* The option '--disable-threads' explicitly requests no locking. */
# elif defined _WIN32 && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# elif HAVE_PTHREAD_API
# include <pthread.h>
# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
# include <threads.h>
# pragma weak thrd_exit
# define c11_threads_in_use() (thrd_exit != NULL)
# else
# define c11_threads_in_use() 0
# endif
# elif HAVE_THREADS_H
# include <threads.h>
# endif
# include "lc-charset-dispatch.h"
# include "mbtowc-lock.h"
static_assert (sizeof (mbstate_t) >= 4);
static char internal_state[4];
size_t
mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
# define FITS_IN_CHAR_TYPE(wc) 1
# include "mbrtowc-impl.h"
}
#else /* glibc, macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Cygwin, mingw, MSVC, Minix, Android */
/* Implement mbrtoc32() based on the original mbrtoc32() or on mbrtowc(). */
# include <wchar.h>
# include "localcharset.h"
# include "streq.h"
# if MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ
# include "hard-locale.h"
# include <locale.h>
# endif
static mbstate_t internal_state;
size_t
mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps)
# undef mbrtoc32
{
/* It's simpler to handle the case s == NULL upfront, than to worry about
this case later, before every test of pwc and n. */
if (s == NULL)
{
pwc = NULL;
s = "";
n = 1;
}
# if MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T
if (n == 0)
return (size_t) -2;
# endif
if (ps == NULL)
ps = &internal_state;
# if HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB && !MBRTOC32_MULTIBYTE_LOCALE_BUG
/* mbrtoc32() may produce different values for wc than mbrtowc(). Therefore
use mbrtoc32(). */
# if defined _WIN32 && !defined __CYGWIN__
char32_t wc;
size_t ret = mbrtoc32 (&wc, s, n, ps);
if (ret < (size_t) -2 && pwc != NULL)
*pwc = wc;
# else
size_t ret = mbrtoc32 (pwc, s, n, ps);
# endif
# if GNULIB_MBRTOC32_REGULAR
/* Verify that mbrtoc32 is regular. */
if (ret < (size_t) -3 && ! mbsinit (ps))
/* This occurs on glibc 2.36. */
mbszero (ps);
if (ret == (size_t) -3)
abort ();
# endif
# if MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ
if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
{
if (pwc != NULL)
*pwc = (unsigned char) *s;
return 1;
}
# endif
return ret;
# elif _GL_SMALL_WCHAR_T
/* Special-case all encodings that may produce wide character values
> WCHAR_MAX. */
const char *encoding = locale_charset ();
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
{
/* Special-case the UTF-8 encoding. Assume that the wide-character
encoding in a UTF-8 locale is UCS-2 or, equivalently, UTF-16. */
/* Here n > 0. */
char *pstate = (char *)ps;
size_t nstate = pstate[0];
char buf[4];
const char *p;
size_t m;
int res;
switch (nstate)
{
case 0:
p = s;
m = n;
break;
case 3:
buf[2] = pstate[3];
FALLTHROUGH;
case 2:
buf[1] = pstate[2];
FALLTHROUGH;
case 1:
buf[0] = pstate[1];
p = buf;
m = nstate;
buf[m++] = s[0];
if (n >= 2 && m < 4)
{
buf[m++] = s[1];
if (n >= 3 && m < 4)
buf[m++] = s[2];
}
break;
default:
errno = EINVAL;
return (size_t)(-1);
}
/* Here m > 0. */
{
# define FITS_IN_CHAR_TYPE(wc) 1
# include "mbrtowc-impl-utf8.h"
}
success:
if (nstate >= (res > 0 ? res : 1))
abort ();
res -= nstate;
/* Set *ps to an initial state. */
# if defined _WIN32 && !defined __CYGWIN__
/* Native Windows. */
/* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4 bytes matter.
On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
as an 8-byte struct, of which the first 4 bytes matter. */
*(unsigned int *)pstate = 0;
# elif defined __CYGWIN__
/* Cygwin defines 'mbstate_t' as an 8-byte struct; the first 4 bytes
matter. */
ps->__count = 0;
# else
pstate[0] = 0;
# endif
return res;
incomplete:
{
size_t k = nstate;
/* Here 0 <= k < m < 4. */
pstate[++k] = s[0];
if (k < m)
{
pstate[++k] = s[1];
if (k < m)
pstate[++k] = s[2];
}
if (k != m)
abort ();
}
pstate[0] = m;
return (size_t)(-2);
invalid:
errno = EILSEQ;
/* The conversion state is undefined, says POSIX. */
return (size_t)(-1);
}
else
{
wchar_t wc;
size_t ret = mbrtowc (&wc, s, n, ps);
if (ret < (size_t) -2 && pwc != NULL)
*pwc = wc;
return ret;
}
# else
/* char32_t and wchar_t are equivalent. Use mbrtowc(). */
wchar_t wc;
size_t ret = mbrtowc (&wc, s, n, ps);
# if GNULIB_MBRTOC32_REGULAR
/* Ensure that mbrtoc32 is regular. */
if (ret < (size_t) -2 && ! mbsinit (ps))
/* This occurs on glibc 2.12. */
mbszero (ps);
# endif
# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
if (ret < (size_t) -2 && wc != 0)
{
wc = locale_encoding_to_unicode (wc);
if (wc == 0)
{
ret = (size_t) -1;
errno = EILSEQ;
}
}
# endif
if (ret < (size_t) -2 && pwc != NULL)
*pwc = wc;
return ret;
# endif
}
#endif

View File

@@ -1,161 +0,0 @@
/* Convert multibyte character to wide character.
Copyright (C) 1999-2002, 2005-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wchar.h>
#if GNULIB_defined_mbstate_t
/* Implement mbrtowc() on top of mbtowc() for the non-UTF-8 locales
and directly for the UTF-8 locales. */
# include <errno.h>
# include <stdint.h>
# include <stdlib.h>
# if AVOID_ANY_THREADS
/* The option '--disable-threads' explicitly requests no locking. */
# elif defined _WIN32 && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# elif HAVE_PTHREAD_API
# include <pthread.h>
# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
# include <threads.h>
# pragma weak thrd_exit
# define c11_threads_in_use() (thrd_exit != NULL)
# else
# define c11_threads_in_use() 0
# endif
# elif HAVE_THREADS_H
# include <threads.h>
# endif
# include "attribute.h"
# include "lc-charset-dispatch.h"
# include "mbtowc-lock.h"
static_assert (sizeof (mbstate_t) >= 4);
static char internal_state[4];
size_t
mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
# define FITS_IN_CHAR_TYPE(wc) ((wc) <= WCHAR_MAX)
# include "mbrtowc-impl.h"
}
#else
/* Override the system's mbrtowc() function. */
# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
# include "hard-locale.h"
# include <locale.h>
# endif
# undef mbrtowc
size_t
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
size_t ret;
wchar_t wc;
# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
if (s == NULL)
{
pwc = NULL;
s = "";
n = 1;
}
# endif
# if MBRTOWC_EMPTY_INPUT_BUG
if (n == 0)
return (size_t) -2;
# endif
if (! pwc)
pwc = &wc;
# if MBRTOWC_RETVAL_BUG
{
static mbstate_t internal_state;
/* Override mbrtowc's internal state. We cannot call mbsinit() on the
hidden internal state, but we can call it on our variable. */
if (ps == NULL)
ps = &internal_state;
if (!mbsinit (ps))
{
/* Parse the rest of the multibyte character byte for byte. */
size_t count = 0;
for (; n > 0; s++, n--)
{
ret = mbrtowc (&wc, s, 1, ps);
if (ret == (size_t)(-1))
return (size_t)(-1);
count++;
if (ret != (size_t)(-2))
{
/* The multibyte character has been completed. */
*pwc = wc;
return (wc == 0 ? 0 : count);
}
}
return (size_t)(-2);
}
}
# endif
# if MBRTOWC_STORES_INCOMPLETE_BUG
ret = mbrtowc (&wc, s, n, ps);
if (ret < (size_t) -2 && pwc != NULL)
*pwc = wc;
# else
ret = mbrtowc (pwc, s, n, ps);
# endif
# if MBRTOWC_NUL_RETVAL_BUG
if (ret < (size_t) -2 && !*pwc)
return 0;
# endif
# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
{
unsigned char uc = *s;
*pwc = uc;
return 1;
}
# endif
return ret;
}
#endif

View File

@@ -1,23 +0,0 @@
/* Put an mbstate_t into an initial conversion state.
Copyright (C) 2023-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
#include <config.h>
#define IN_MBSZERO
/* Specification and implementation. */
#include <wchar.h>

View File

@@ -1,585 +0,0 @@
/* nl_langinfo() replacement: query locale dependent information.
Copyright (C) 2007-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <langinfo.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#if defined _WIN32 && ! defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# include <stdio.h>
#endif
#if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE
# if AVOID_ANY_THREADS
/* The option '--disable-threads' explicitly requests no locking. */
# elif defined _WIN32 && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# elif HAVE_PTHREAD_API
# include <pthread.h>
# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
# include <threads.h>
# pragma weak thrd_exit
# define c11_threads_in_use() (thrd_exit != NULL)
# else
# define c11_threads_in_use() 0
# endif
# elif HAVE_THREADS_H
# include <threads.h>
# endif
#endif
/* nl_langinfo() must be multithread-safe. To achieve this without using
thread-local storage:
1. We use a specific static buffer for each possible argument.
So that different threads can call nl_langinfo with different arguments,
without interfering.
2. We use a simple strcpy or memcpy to fill this static buffer. Filling it
through, for example, strcpy + strcat would not be guaranteed to leave
the buffer's contents intact if another thread is currently accessing
it. If necessary, the contents is first assembled in a stack-allocated
buffer. */
#if !REPLACE_NL_LANGINFO || GNULIB_defined_CODESET
/* Return the codeset of the current locale, if this is easily deducible.
Otherwise, return "". */
static char *
ctype_codeset (void)
{
/* This function is only used on platforms which don't have uselocale().
Therefore we don't need to look at the per-thread locale first, here. */
static char result[2 + 10 + 1];
char buf[2 + 10 + 1];
char locale[SETLOCALE_NULL_MAX];
char *codeset;
size_t codesetlen;
if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale)))
locale[0] = '\0';
codeset = buf;
codeset[0] = '\0';
if (locale[0])
{
/* If the locale name contains an encoding after the dot, return it. */
char *dot = strchr (locale, '.');
if (dot)
{
/* Look for the possible @... trailer and remove it, if any. */
char *codeset_start = dot + 1;
char const *modifier = strchr (codeset_start, '@');
if (! modifier)
codeset = codeset_start;
else
{
codesetlen = modifier - codeset_start;
if (codesetlen < sizeof buf)
{
codeset = memcpy (buf, codeset_start, codesetlen);
codeset[codesetlen] = '\0';
}
}
}
}
# if defined _WIN32 && ! defined __CYGWIN__
/* If setlocale is successful, it returns the number of the
codepage, as a string. Otherwise, fall back on Windows API
GetACP, which returns the locale's codepage as a number (although
this doesn't change according to what the 'setlocale' call specified).
Either way, prepend "CP" to make it a valid codeset name. */
codesetlen = strlen (codeset);
if (0 < codesetlen && codesetlen < sizeof buf - 2)
memmove (buf + 2, codeset, codesetlen + 1);
else
sprintf (buf + 2, "%u", GetACP ());
/* For a locale name such as "French_France.65001", in Windows 10,
setlocale now returns "French_France.utf8" instead. */
if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
return (char *) "UTF-8";
else
{
memcpy (buf, "CP", 2);
strcpy (result, buf);
return result;
}
# else
strcpy (result, codeset);
return result;
#endif
}
#endif
#if REPLACE_NL_LANGINFO
/* Override nl_langinfo with support for added nl_item values. */
# undef nl_langinfo
/* Without locking, on Solaris 11.3, test-nl_langinfo-mt fails, with message
"thread5 disturbed by threadN!", even when threadN invokes only
nl_langinfo (CODESET);
nl_langinfo (CRNCYSTR);
Similarly on Solaris 10. */
# if !NL_LANGINFO_MTSAFE /* Solaris */
# define ITEMS (MAXSTRMSG + 1)
# define MAX_RESULT_LEN 80
static char *
nl_langinfo_unlocked (nl_item item)
{
static char result[ITEMS][MAX_RESULT_LEN];
/* The result of nl_langinfo is in storage that can be overwritten by
other calls to nl_langinfo. */
char *tmp = nl_langinfo (item);
if (item >= 0 && item < ITEMS && tmp != NULL)
{
size_t tmp_len = strlen (tmp);
if (tmp_len < MAX_RESULT_LEN)
strcpy (result[item], tmp);
else
{
/* Produce a truncated result. Oh well... */
result[item][MAX_RESULT_LEN - 1] = '\0';
memcpy (result[item], tmp, MAX_RESULT_LEN - 1);
}
return result[item];
}
else
return tmp;
}
/* Use a lock, so that no two threads can invoke nl_langinfo_unlocked
at the same time. */
/* Prohibit renaming this symbol. */
# undef gl_get_nl_langinfo_lock
# if AVOID_ANY_THREADS
/* The option '--disable-threads' explicitly requests no locking. */
# define nl_langinfo_with_lock nl_langinfo_unlocked
# elif defined _WIN32 && !defined __CYGWIN__
extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
static char *
nl_langinfo_with_lock (nl_item item)
{
CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock ();
char *ret;
EnterCriticalSection (lock);
ret = nl_langinfo_unlocked (item);
LeaveCriticalSection (lock);
return ret;
}
# elif HAVE_PTHREAD_API
extern
# if defined _WIN32 || defined __CYGWIN__
__declspec(dllimport)
# endif
pthread_mutex_t *gl_get_nl_langinfo_lock (void);
# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */
/* Avoid the need to link with '-lpthread'. */
# pragma weak pthread_mutex_lock
# pragma weak pthread_mutex_unlock
/* Determine whether libpthread is in use. */
# pragma weak pthread_mutexattr_gettype
/* See the comments in lock.h. */
# define pthread_in_use() \
(pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
# else
# define pthread_in_use() 1
# endif
static char *
nl_langinfo_with_lock (nl_item item)
{
if (pthread_in_use())
{
pthread_mutex_t *lock = gl_get_nl_langinfo_lock ();
char *ret;
if (pthread_mutex_lock (lock))
abort ();
ret = nl_langinfo_unlocked (item);
if (pthread_mutex_unlock (lock))
abort ();
return ret;
}
else
return nl_langinfo_unlocked (item);
}
# elif HAVE_THREADS_H
extern mtx_t *gl_get_nl_langinfo_lock (void);
static char *
nl_langinfo_with_lock (nl_item item)
{
mtx_t *lock = gl_get_nl_langinfo_lock ();
char *ret;
if (mtx_lock (lock) != thrd_success)
abort ();
ret = nl_langinfo_unlocked (item);
if (mtx_unlock (lock) != thrd_success)
abort ();
return ret;
}
# endif
# else
/* On other platforms, no lock is needed. */
# define nl_langinfo_with_lock nl_langinfo
# endif
char *
rpl_nl_langinfo (nl_item item)
{
switch (item)
{
# if GNULIB_defined_CODESET
case CODESET:
return ctype_codeset ();
# endif
# if GNULIB_defined_T_FMT_AMPM
case T_FMT_AMPM:
return (char *) "%I:%M:%S %p";
# endif
# if GNULIB_defined_ALTMON
case ALTMON_1:
case ALTMON_2:
case ALTMON_3:
case ALTMON_4:
case ALTMON_5:
case ALTMON_6:
case ALTMON_7:
case ALTMON_8:
case ALTMON_9:
case ALTMON_10:
case ALTMON_11:
case ALTMON_12:
/* We don't ship the appropriate localizations with gnulib. Therefore,
treat ALTMON_i like MON_i. */
item = item - ALTMON_1 + MON_1;
break;
# endif
# if GNULIB_defined_ERA
case ERA:
/* The format is not standardized. In glibc it is a sequence of strings
of the form "direction:offset:start_date:end_date:era_name:era_format"
with an empty string at the end. */
return (char *) "";
case ERA_D_FMT:
/* The %Ex conversion in strftime behaves like %x if the locale does not
have an alternative time format. */
item = D_FMT;
break;
case ERA_D_T_FMT:
/* The %Ec conversion in strftime behaves like %c if the locale does not
have an alternative time format. */
item = D_T_FMT;
break;
case ERA_T_FMT:
/* The %EX conversion in strftime behaves like %X if the locale does not
have an alternative time format. */
item = T_FMT;
break;
case ALT_DIGITS:
/* The format is not standardized. In glibc it is a sequence of 10
strings, appended in memory. */
return (char *) "\0\0\0\0\0\0\0\0\0\0";
# endif
# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
case YESEXPR:
return (char *) "^[yY]";
case NOEXPR:
return (char *) "^[nN]";
# endif
default:
break;
}
return nl_langinfo_with_lock (item);
}
#else
/* Provide nl_langinfo from scratch, either for native MS-Windows, or
for old Unix platforms without locales, such as Linux libc5 or
BeOS. */
# include <time.h>
char *
nl_langinfo (nl_item item)
{
char buf[100];
struct tm tmm = { 0 };
switch (item)
{
/* nl_langinfo items of the LC_CTYPE category */
case CODESET:
{
char *codeset = ctype_codeset ();
if (*codeset)
return codeset;
}
# ifdef __BEOS__
return (char *) "UTF-8";
# else
return (char *) "ISO-8859-1";
# endif
/* nl_langinfo items of the LC_NUMERIC category */
case RADIXCHAR:
return localeconv () ->decimal_point;
case THOUSEP:
return localeconv () ->thousands_sep;
# ifdef GROUPING
case GROUPING:
return localeconv () ->grouping;
# endif
/* nl_langinfo items of the LC_TIME category.
TODO: Really use the locale. */
case D_T_FMT:
case ERA_D_T_FMT:
return (char *) "%a %b %e %H:%M:%S %Y";
case D_FMT:
case ERA_D_FMT:
return (char *) "%m/%d/%y";
case T_FMT:
case ERA_T_FMT:
return (char *) "%H:%M:%S";
case T_FMT_AMPM:
return (char *) "%I:%M:%S %p";
case AM_STR:
{
static char result[80];
if (!strftime (buf, sizeof result, "%p", &tmm))
return (char *) "AM";
strcpy (result, buf);
return result;
}
case PM_STR:
{
static char result[80];
tmm.tm_hour = 12;
if (!strftime (buf, sizeof result, "%p", &tmm))
return (char *) "PM";
strcpy (result, buf);
return result;
}
case DAY_1:
case DAY_2:
case DAY_3:
case DAY_4:
case DAY_5:
case DAY_6:
case DAY_7:
{
static char result[7][50];
static char const days[][sizeof "Wednesday"] = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"
};
tmm.tm_wday = item - DAY_1;
if (!strftime (buf, sizeof result[0], "%A", &tmm))
return (char *) days[item - DAY_1];
strcpy (result[item - DAY_1], buf);
return result[item - DAY_1];
}
case ABDAY_1:
case ABDAY_2:
case ABDAY_3:
case ABDAY_4:
case ABDAY_5:
case ABDAY_6:
case ABDAY_7:
{
static char result[7][30];
static char const abdays[][sizeof "Sun"] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
tmm.tm_wday = item - ABDAY_1;
if (!strftime (buf, sizeof result[0], "%a", &tmm))
return (char *) abdays[item - ABDAY_1];
strcpy (result[item - ABDAY_1], buf);
return result[item - ABDAY_1];
}
{
static char const months[][sizeof "September"] = {
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
};
case MON_1:
case MON_2:
case MON_3:
case MON_4:
case MON_5:
case MON_6:
case MON_7:
case MON_8:
case MON_9:
case MON_10:
case MON_11:
case MON_12:
{
static char result[12][50];
tmm.tm_mon = item - MON_1;
if (!strftime (buf, sizeof result[0], "%B", &tmm))
return (char *) months[item - MON_1];
strcpy (result[item - MON_1], buf);
return result[item - MON_1];
}
case ALTMON_1:
case ALTMON_2:
case ALTMON_3:
case ALTMON_4:
case ALTMON_5:
case ALTMON_6:
case ALTMON_7:
case ALTMON_8:
case ALTMON_9:
case ALTMON_10:
case ALTMON_11:
case ALTMON_12:
{
static char result[12][50];
tmm.tm_mon = item - ALTMON_1;
/* The platforms without nl_langinfo() don't support strftime with
%OB. We don't even need to try. */
#if 0
if (!strftime (buf, sizeof result[0], "%OB", &tmm))
#endif
if (!strftime (buf, sizeof result[0], "%B", &tmm))
return (char *) months[item - ALTMON_1];
strcpy (result[item - ALTMON_1], buf);
return result[item - ALTMON_1];
}
}
case ABMON_1:
case ABMON_2:
case ABMON_3:
case ABMON_4:
case ABMON_5:
case ABMON_6:
case ABMON_7:
case ABMON_8:
case ABMON_9:
case ABMON_10:
case ABMON_11:
case ABMON_12:
{
static char result[12][30];
static char const abmonths[][sizeof "Jan"] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"
};
tmm.tm_mon = item - ABMON_1;
if (!strftime (buf, sizeof result[0], "%b", &tmm))
return (char *) abmonths[item - ABMON_1];
strcpy (result[item - ABMON_1], buf);
return result[item - ABMON_1];
}
case ERA:
return (char *) "";
case ALT_DIGITS:
return (char *) "\0\0\0\0\0\0\0\0\0\0";
/* nl_langinfo items of the LC_MONETARY category. */
case CRNCYSTR:
return localeconv () ->currency_symbol;
# ifdef INT_CURR_SYMBOL
case INT_CURR_SYMBOL:
return localeconv () ->int_curr_symbol;
case MON_DECIMAL_POINT:
return localeconv () ->mon_decimal_point;
case MON_THOUSANDS_SEP:
return localeconv () ->mon_thousands_sep;
case MON_GROUPING:
return localeconv () ->mon_grouping;
case POSITIVE_SIGN:
return localeconv () ->positive_sign;
case NEGATIVE_SIGN:
return localeconv () ->negative_sign;
case FRAC_DIGITS:
return & localeconv () ->frac_digits;
case INT_FRAC_DIGITS:
return & localeconv () ->int_frac_digits;
case P_CS_PRECEDES:
return & localeconv () ->p_cs_precedes;
case N_CS_PRECEDES:
return & localeconv () ->n_cs_precedes;
case P_SEP_BY_SPACE:
return & localeconv () ->p_sep_by_space;
case N_SEP_BY_SPACE:
return & localeconv () ->n_sep_by_space;
case P_SIGN_POSN:
return & localeconv () ->p_sign_posn;
case N_SIGN_POSN:
return & localeconv () ->n_sign_posn;
# endif
/* nl_langinfo items of the LC_MESSAGES category
TODO: Really use the locale. */
case YESEXPR:
return (char *) "^[yY]";
case NOEXPR:
return (char *) "^[nN]";
default:
return (char *) "";
}
}
#endif

View File

@@ -1,92 +0,0 @@
/* Program name management.
Copyright (C) 2001-2003, 2005-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2001.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */
#include "progname.h"
#include <errno.h> /* get program_invocation_name declaration */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* String containing name the program is called with.
To be initialized by main(). */
const char *program_name = NULL;
/* Set program_name, based on argv[0].
argv0 must be a string allocated with indefinite extent, and must not be
modified after this call. */
void
set_program_name (const char *argv0)
{
/* libtool creates a temporary executable whose name is sometimes prefixed
with "lt-" (depends on the platform). It also makes argv[0] absolute.
But the name of the temporary executable is a detail that should not be
visible to the end user and to the test suite.
Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */
const char *slash;
const char *base;
/* Sanity check. POSIX requires the invoking process to pass a non-NULL
argv[0]. */
if (argv0 == NULL)
{
/* It's a bug in the invoking program. Help diagnosing it. */
fputs ("A NULL argv[0] was passed through an exec system call.\n",
stderr);
abort ();
}
slash = strrchr (argv0, '/');
base = (slash != NULL ? slash + 1 : argv0);
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
{
argv0 = base;
if (strncmp (base, "lt-", 3) == 0)
{
argv0 = base + 3;
/* On glibc systems, remove the "lt-" prefix from the variable
program_invocation_short_name. */
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
program_invocation_short_name = (char *) argv0;
#endif
}
}
/* But don't strip off a leading <dirname>/ in general, because when the user
runs
/some/hidden/place/bin/cp foo foo
he should get the error message
/some/hidden/place/bin/cp: `foo' and `foo' are the same file
not
cp: `foo' and `foo' are the same file
*/
program_name = argv0;
/* On glibc systems, the error() function comes from libc and uses the
variable program_invocation_name, not program_name. So set this variable
as well. */
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = (char *) argv0;
#endif
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,135 +0,0 @@
/* Searching in a string.
Copyright (C) 2008-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <string.h>
/* A function definition is needed only if HAVE_RAWMEMCHR is not defined. */
#if !HAVE_RAWMEMCHR
# include <limits.h>
# include <stdint.h>
/* Find the first occurrence of C in S. */
void *
rawmemchr (const void *s, int c_in)
{
# ifdef __CHERI_PURE_CAPABILITY__
/* Most architectures let you read an aligned word,
even if the unsigned char array at S ends in the middle of the word.
However CHERI does not, so call memchr
with the underlying object's remaining length.
This cannot return NULL if S points to a C_IN-terminated array.
Use builtins rather than including <cheri.h> which is less stable. */
return memchr (s, c_in, (__builtin_cheri_length_get (s)
- __builtin_cheri_offset_get (s)));
# else
/* You can change this typedef to experiment with performance. */
typedef uintptr_t longword;
/* Verify that the longword type lacks padding bits. */
static_assert (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (uintptr_t));
const unsigned char *char_ptr;
unsigned char c = c_in;
/* Handle the first few bytes by reading one byte at a time.
Do this until CHAR_PTR is aligned on a natural longword boundary,
as using alignof (longword) might be slower. */
for (char_ptr = (const unsigned char *) s;
(uintptr_t) char_ptr % sizeof (longword) != 0;
++char_ptr)
if (*char_ptr == c)
return (void *) char_ptr;
longword const *longword_ptr = s = char_ptr;
/* Compute auxiliary longword values:
repeated_one is a value which has a 1 in every byte.
repeated_c has c in every byte. */
longword repeated_one = (longword) -1 / UCHAR_MAX;
longword repeated_c = repeated_one * c;
longword repeated_hibit = repeated_one * (UCHAR_MAX / 2 + 1);
/* Instead of the traditional loop which tests each byte, we will
test a longword at a time. The tricky part is testing if any of
the bytes in the longword in question are equal to
c. We first use an xor with repeated_c. This reduces the task
to testing whether any of the bytes in longword1 is zero.
(The following comments assume 8-bit bytes, as POSIX requires;
the code's use of UCHAR_MAX should work even if bytes have more
than 8 bits.)
We compute tmp =
((longword1 - repeated_one) & ~longword1) & (repeated_one * 0x80).
That is, we perform the following operations:
1. Subtract repeated_one.
2. & ~longword1.
3. & a mask consisting of 0x80 in every byte.
Consider what happens in each byte:
- If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
and step 3 transforms it into 0x80. A carry can also be propagated
to more significant bytes.
- If a byte of longword1 is nonzero, let its lowest 1 bit be at
position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
the byte ends in a single bit of value 0 and k bits of value 1.
After step 2, the result is just k bits of value 1: 2^k - 1. After
step 3, the result is 0. And no carry is produced.
So, if longword1 has only non-zero bytes, tmp is zero.
Whereas if longword1 has a zero byte, call j the position of the least
significant zero byte. Then the result has a zero at positions 0, ...,
j-1 and a 0x80 at position j. We cannot predict the result at the more
significant bytes (positions j+1..3), but it does not matter since we
already have a non-zero bit at position 8*j+7.
The test whether any byte in longword1 is zero is equivalent
to testing whether tmp is nonzero.
This test can read beyond the end of a string, depending on where
C_IN is encountered. However, this is considered safe since the
initialization phase ensured that the read will be aligned,
therefore, the read will not cross page boundaries and will not
cause a fault. */
while (1)
{
longword longword1 = *longword_ptr ^ repeated_c;
if ((((longword1 - repeated_one) & ~longword1) & repeated_hibit) != 0)
break;
longword_ptr++;
}
char_ptr = s = longword_ptr;
/* At this point, we know that one of the sizeof (longword) bytes
starting at char_ptr is == c. If we knew endianness, we
could determine the first such byte without any further memory
accesses, just by looking at the tmp result from the last loop
iteration. However, the following simple and portable code does
not attempt this potential optimization. */
while (*char_ptr != c)
char_ptr++;
return (void *) char_ptr;
# endif
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,80 +0,0 @@
/* Extended regular expression matching and search library.
Copyright (C) 2002-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#define __STDC_WANT_IEC_60559_BFP_EXT__
#ifndef _LIBC
# include <libc-config.h>
# if __GNUC_PREREQ (4, 6)
# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
# pragma GCC diagnostic ignored "-Wvla"
# endif
#endif
/* Make sure no one compiles this code with a C++ compiler. */
#if defined __cplusplus && defined _LIBC
# error "This is C code, use a C compiler"
#endif
#ifdef _LIBC
/* We have to keep the namespace clean. */
# define regfree(preg) __regfree (preg)
# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
# define regerror(errcode, preg, errbuf, errbuf_size) \
__regerror(errcode, preg, errbuf, errbuf_size)
# define re_set_registers(bu, re, nu, st, en) \
__re_set_registers (bu, re, nu, st, en)
# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
__re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
# define re_match(bufp, string, size, pos, regs) \
__re_match (bufp, string, size, pos, regs)
# define re_search(bufp, string, size, startpos, range, regs) \
__re_search (bufp, string, size, startpos, range, regs)
# define re_compile_pattern(pattern, length, bufp) \
__re_compile_pattern (pattern, length, bufp)
# define re_set_syntax(syntax) __re_set_syntax (syntax)
# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
__re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
# include "../locale/localeinfo.h"
#endif
/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
GNU regex allows. Include it before <regex.h>, which correctly
#undefs RE_DUP_MAX and sets it to the right value. */
#include <limits.h>
#include <regex.h>
#include "regex_internal.h"
#include "regex_internal.c"
#include "regcomp.c"
#include "regexec.c"
/* Binary backward compatibility. */
#if _LIBC
# include <shlib-compat.h>
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
int re_max_failures = 2000;
# endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,175 +0,0 @@
/* Determine whether string value is affirmation or negative response
according to current locale's data.
Copyright (C) 1996, 1998, 2000, 2002-2003, 2006-2024 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <stdlib.h>
#include <stddef.h>
#if ENABLE_NLS
# include <sys/types.h>
# include <limits.h>
# include <string.h>
# if HAVE_LANGINFO_YESEXPR
# include <langinfo.h>
# endif
# include <regex.h>
# include "gettext.h"
# define _(msgid) gettext (msgid)
# define N_(msgid) gettext_noop (msgid)
# if HAVE_LANGINFO_YESEXPR
/* Return the localized regular expression pattern corresponding to
ENGLISH_PATTERN. NL_INDEX can be used with nl_langinfo.
The resulting string may only be used until the next nl_langinfo call. */
static const char *
localized_pattern (const char *english_pattern, nl_item nl_index,
bool posixly_correct)
{
const char *translated_pattern;
/* We prefer to get the patterns from a PO file. It would be possible to
always use nl_langinfo (YESEXPR) instead of _("^[yY]"), and
nl_langinfo (NOEXPR) instead of _("^[nN]"), if we could assume that the
system's locale support is good. But this is not the case e.g. on Cygwin.
The localizations of gnulib.pot are of better quality in general.
Also, if we use locale info from non-free systems that don't have a
'localedef' command, we deprive the users of the freedom to localize
this pattern for their preferred language.
But some programs, such as 'cp', 'mv', 'rm', 'find', 'xargs', are
specified by POSIX to use nl_langinfo (YESEXPR). We implement this
behaviour if POSIXLY_CORRECT is set, for the sake of these programs. */
/* If the user wants strict POSIX compliance, use nl_langinfo. */
if (posixly_correct)
{
translated_pattern = nl_langinfo (nl_index);
/* Check against a broken system return value. */
if (translated_pattern != NULL && translated_pattern[0] != '\0')
return translated_pattern;
}
/* Look in the gnulib message catalog. */
translated_pattern = _(english_pattern);
if (translated_pattern == english_pattern)
{
/* The gnulib message catalog provides no translation.
Try the system's message catalog. */
translated_pattern = nl_langinfo (nl_index);
/* Check against a broken system return value. */
if (translated_pattern != NULL && translated_pattern[0] != '\0')
return translated_pattern;
/* Fall back to English. */
translated_pattern = english_pattern;
}
return translated_pattern;
}
# else
# define localized_pattern(english_pattern,nl_index,posixly_correct) \
_(english_pattern)
# endif
static int
try (const char *response, const char *pattern, char **lastp, regex_t *re)
{
if (*lastp == NULL || strcmp (pattern, *lastp) != 0)
{
char *safe_pattern;
/* The pattern has changed. */
if (*lastp != NULL)
{
/* Free the old compiled pattern. */
regfree (re);
free (*lastp);
*lastp = NULL;
}
/* Put the PATTERN into safe memory before calling regcomp.
(regcomp may call nl_langinfo, overwriting PATTERN's storage. */
safe_pattern = strdup (pattern);
if (safe_pattern == NULL)
return -1;
/* Compile the pattern and cache it for future runs. */
if (regcomp (re, safe_pattern, REG_EXTENDED) != 0)
{
free (safe_pattern);
return -1;
}
*lastp = safe_pattern;
}
/* See if the regular expression matches RESPONSE. */
return regexec (re, response, 0, NULL, 0) == 0;
}
#endif
int
rpmatch (const char *response)
{
#if ENABLE_NLS
/* Match against one of the response patterns, compiling the pattern
first if necessary. */
/* We cache the response patterns and compiled regexps here. */
static char *last_yesexpr, *last_noexpr;
static regex_t cached_yesre, cached_nore;
# if HAVE_LANGINFO_YESEXPR
bool posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
# endif
const char *yesexpr, *noexpr;
int result;
/* TRANSLATORS: A regular expression testing for an affirmative answer
(english: "yes"). Testing the first character may be sufficient.
Take care to consider upper and lower case.
To enquire the regular expression that your system uses for this
purpose, you can use the command
locale -k LC_MESSAGES | grep '^yesexpr=' */
yesexpr = localized_pattern (N_("^[yY]"), YESEXPR, posixly_correct);
result = try (response, yesexpr, &last_yesexpr, &cached_yesre);
if (result < 0)
return -1;
if (result)
return 1;
/* TRANSLATORS: A regular expression testing for a negative answer
(english: "no"). Testing the first character may be sufficient.
Take care to consider upper and lower case.
To enquire the regular expression that your system uses for this
purpose, you can use the command
locale -k LC_MESSAGES | grep '^noexpr=' */
noexpr = localized_pattern (N_("^[nN]"), NOEXPR, posixly_correct);
result = try (response, noexpr, &last_noexpr, &cached_nore);
if (result < 0)
return -1;
if (result)
return 0;
return -1;
#else
/* Test against "^[yY]" and "^[nN]", hardcoded to avoid requiring regex */
return (*response == 'y' || *response == 'Y' ? 1
: *response == 'n' || *response == 'N' ? 0 : -1);
#endif
}

View File

@@ -1,71 +0,0 @@
/* An interface to read and write that retries after interrupts.
Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2024 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#ifdef SAFE_WRITE
# include "safe-write.h"
#else
# include "safe-read.h"
#endif
/* Get ssize_t. */
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#ifdef EINTR
# define IS_EINTR(x) ((x) == EINTR)
#else
# define IS_EINTR(x) 0
#endif
#include "sys-limits.h"
#ifdef SAFE_WRITE
# define safe_rw safe_write
# define rw write
typedef void const *bufptr;
#else
# define safe_rw safe_read
# define rw read
typedef void *bufptr;
#endif
/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
interrupted. Return the number of bytes read(written), zero for EOF,
or -1 upon error. */
ptrdiff_t
safe_rw (int fd, bufptr buf, idx_t count)
{
for (;;)
{
ssize_t result = rw (fd, buf, count <= (size_t) -1 ? count : (size_t) -1);
if (0 <= result)
return result;
else if (IS_EINTR (errno))
continue;
else if (errno == EINVAL && SYS_BUFSIZE_MAX < count)
count = SYS_BUFSIZE_MAX;
else
return result;
}
}

View File

@@ -1,151 +0,0 @@
/* Return the internal lock used by setlocale_null_r.
Copyright (C) 2019-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
#include <config.h>
/* The option '--disable-threads' explicitly requests no locking. */
/* When it is known that the gl_get_setlocale_null_lock function is defined
by a dependency library, it should not be defined here. */
#if AVOID_ANY_THREADS || OMIT_SETLOCALE_LOCK
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
typedef int dummy;
#else
/* This file defines the internal lock used by setlocale_null_r.
It is a separate compilation unit, so that only one copy of it is
present when linking statically. */
/* Prohibit renaming this symbol. */
# undef gl_get_setlocale_null_lock
/* Macro for exporting a symbol (function, not variable) defined in this file,
when compiled into a shared library. */
# ifndef SHLIB_EXPORTED
# if HAVE_VISIBILITY
/* Override the effect of the compiler option '-fvisibility=hidden'. */
# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
# elif defined _WIN32 || defined __CYGWIN__
# define SHLIB_EXPORTED __declspec(dllexport)
# else
# define SHLIB_EXPORTED
# endif
# endif
# if defined _WIN32 && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# include "windows-initguard.h"
/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
because the latter is not guaranteed to be a stable ABI in the future. */
/* Make sure the function gets exported from DLLs. */
SHLIB_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
static CRITICAL_SECTION lock;
/* Returns the internal lock used by setlocale_null_r. */
CRITICAL_SECTION *
gl_get_setlocale_null_lock (void)
{
if (!guard.done)
{
if (InterlockedIncrement (&guard.started) == 0)
{
/* This thread is the first one to need the lock. Initialize it. */
InitializeCriticalSection (&lock);
guard.done = 1;
}
else
{
/* Don't let guard.started grow and wrap around. */
InterlockedDecrement (&guard.started);
/* Yield the CPU while waiting for another thread to finish
initializing this mutex. */
while (!guard.done)
Sleep (0);
}
}
return &lock;
}
# elif HAVE_PTHREAD_API
# include <pthread.h>
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
/* Make sure the function gets exported from shared libraries. */
SHLIB_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void);
/* Returns the internal lock used by setlocale_null_r. */
pthread_mutex_t *
gl_get_setlocale_null_lock (void)
{
return &mutex;
}
# elif HAVE_THREADS_H
# include <threads.h>
# include <stdlib.h>
static int volatile init_needed = 1;
static once_flag init_once = ONCE_FLAG_INIT;
static mtx_t mutex;
static void
atomic_init (void)
{
if (mtx_init (&mutex, mtx_plain) != thrd_success)
abort ();
init_needed = 0;
}
/* Make sure the function gets exported from shared libraries. */
SHLIB_EXPORTED mtx_t *gl_get_setlocale_null_lock (void);
/* Returns the internal lock used by setlocale_null_r. */
mtx_t *
gl_get_setlocale_null_lock (void)
{
if (init_needed)
call_once (&init_once, atomic_init);
return &mutex;
}
# endif
# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
/* Make sure the '__declspec(dllimport)' in setlocale_null.c does not cause
a link failure when no DLLs are involved. */
# if defined _WIN64 || defined _LP64
# define IMP(x) __imp_##x
# else
# define IMP(x) _imp__##x
# endif
void * IMP(gl_get_setlocale_null_lock) = &gl_get_setlocale_null_lock;
# endif
#endif

View File

@@ -1,149 +0,0 @@
/* Query the name of the current global locale, without locking.
Copyright (C) 2019-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
#include <config.h>
/* Specification. */
#include "setlocale_null.h"
#include <errno.h>
#include <locale.h>
#include <string.h>
#if defined _WIN32 && !defined __CYGWIN__
# include <wchar.h>
#endif
/* Use the system's setlocale() function, not the gnulib override, here. */
#undef setlocale
const char *
setlocale_null_unlocked (int category)
{
const char *result = setlocale (category, NULL);
#ifdef __ANDROID__
if (result == NULL)
switch (category)
{
case LC_CTYPE:
case LC_NUMERIC:
case LC_TIME:
case LC_COLLATE:
case LC_MONETARY:
case LC_MESSAGES:
case LC_ALL:
case LC_PAPER:
case LC_NAME:
case LC_ADDRESS:
case LC_TELEPHONE:
case LC_MEASUREMENT:
result = "C";
break;
default:
break;
}
#endif
return result;
}
int
setlocale_null_r_unlocked (int category, char *buf, size_t bufsize)
{
#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER
/* On native Windows, nowadays, the setlocale() implementation is based
on _wsetlocale() and uses malloc() for the result. We are better off
using _wsetlocale() directly. */
const wchar_t *result = _wsetlocale (category, NULL);
if (result == NULL)
{
/* CATEGORY is invalid. */
if (bufsize > 0)
/* Return an empty string in BUF.
This is a convenience for callers that don't want to write explicit
code for handling EINVAL. */
buf[0] = '\0';
return EINVAL;
}
else
{
size_t length = wcslen (result);
if (length < bufsize)
{
size_t i;
/* Convert wchar_t[] -> char[], assuming plain ASCII. */
for (i = 0; i <= length; i++)
buf[i] = result[i];
return 0;
}
else
{
if (bufsize > 0)
{
/* Return a truncated result in BUF.
This is a convenience for callers that don't want to write
explicit code for handling ERANGE. */
size_t i;
/* Convert wchar_t[] -> char[], assuming plain ASCII. */
for (i = 0; i < bufsize; i++)
buf[i] = result[i];
buf[bufsize - 1] = '\0';
}
return ERANGE;
}
}
#else
const char *result = setlocale_null_unlocked (category);
if (result == NULL)
{
/* CATEGORY is invalid. */
if (bufsize > 0)
/* Return an empty string in BUF.
This is a convenience for callers that don't want to write explicit
code for handling EINVAL. */
buf[0] = '\0';
return EINVAL;
}
else
{
size_t length = strlen (result);
if (length < bufsize)
{
memcpy (buf, result, length + 1);
return 0;
}
else
{
if (bufsize > 0)
{
/* Return a truncated result in BUF.
This is a convenience for callers that don't want to write
explicit code for handling ERANGE. */
memcpy (buf, result, bufsize - 1);
buf[bufsize - 1] = '\0';
}
return ERANGE;
}
}
#endif
}

View File

@@ -1,299 +0,0 @@
/* Query the name of the current global locale.
Copyright (C) 2019-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
#include <config.h>
/* Specification. */
#include "setlocale_null.h"
#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE)
# if AVOID_ANY_THREADS
/* The option '--disable-threads' explicitly requests no locking. */
# elif defined _WIN32 && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# elif HAVE_PTHREAD_API
# include <pthread.h>
# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
# include <threads.h>
# pragma weak thrd_exit
# define c11_threads_in_use() (thrd_exit != NULL)
# else
# define c11_threads_in_use() 0
# endif
# elif HAVE_THREADS_H
# include <threads.h>
# endif
#endif
#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */
/* Use a lock, so that no two threads can invoke setlocale_null_r_unlocked
at the same time. */
/* Prohibit renaming this symbol. */
# undef gl_get_setlocale_null_lock
# if AVOID_ANY_THREADS
/* The option '--disable-threads' explicitly requests no locking. */
# define setlocale_null_r_with_lock setlocale_null_r_unlocked
# elif defined _WIN32 && !defined __CYGWIN__
extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
static int
setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
{
CRITICAL_SECTION *lock = gl_get_setlocale_null_lock ();
int ret;
EnterCriticalSection (lock);
ret = setlocale_null_r_unlocked (category, buf, bufsize);
LeaveCriticalSection (lock);
return ret;
}
# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */
extern
# if defined _WIN32 || defined __CYGWIN__
__declspec(dllimport)
# endif
pthread_mutex_t *gl_get_setlocale_null_lock (void);
# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */
/* Avoid the need to link with '-lpthread'. */
# pragma weak pthread_mutex_lock
# pragma weak pthread_mutex_unlock
/* Determine whether libpthread is in use. */
# pragma weak pthread_mutexattr_gettype
/* See the comments in lock.h. */
# define pthread_in_use() \
(pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
# else
# define pthread_in_use() 1
# endif
static int
setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
{
if (pthread_in_use())
{
pthread_mutex_t *lock = gl_get_setlocale_null_lock ();
int ret;
if (pthread_mutex_lock (lock))
abort ();
ret = setlocale_null_r_unlocked (category, buf, bufsize);
if (pthread_mutex_unlock (lock))
abort ();
return ret;
}
else
return setlocale_null_r_unlocked (category, buf, bufsize);
}
# elif HAVE_THREADS_H
extern mtx_t *gl_get_setlocale_null_lock (void);
static int
setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
{
mtx_t *lock = gl_get_setlocale_null_lock ();
int ret;
if (mtx_lock (lock) != thrd_success)
abort ();
ret = setlocale_null_r_unlocked (category, buf, bufsize);
if (mtx_unlock (lock) != thrd_success)
abort ();
return ret;
}
# endif
#endif
int
setlocale_null_r (int category, char *buf, size_t bufsize)
{
#if SETLOCALE_NULL_ALL_MTSAFE
# if SETLOCALE_NULL_ONE_MTSAFE
return setlocale_null_r_unlocked (category, buf, bufsize);
# else
if (category == LC_ALL)
return setlocale_null_r_unlocked (category, buf, bufsize);
else
return setlocale_null_r_with_lock (category, buf, bufsize);
# endif
#else
# if SETLOCALE_NULL_ONE_MTSAFE
if (category == LC_ALL)
return setlocale_null_r_with_lock (category, buf, bufsize);
else
return setlocale_null_r_unlocked (category, buf, bufsize);
# else
return setlocale_null_r_with_lock (category, buf, bufsize);
# endif
#endif
}
const char *
setlocale_null (int category)
{
#if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE
return setlocale_null_unlocked (category);
#else
/* This call must be multithread-safe. To achieve this without using
thread-local storage:
1. We use a specific static buffer for each possible CATEGORY
argument. So that different threads can call setlocale_mtsafe
with different CATEGORY arguments, without interfering.
2. We use a simple strcpy or memcpy to fill this static buffer.
Filling it through, for example, strcpy + strcat would not be
guaranteed to leave the buffer's contents intact if another thread
is currently accessing it. If necessary, the contents is first
assembled in a stack-allocated buffer. */
if (category == LC_ALL)
{
# if SETLOCALE_NULL_ALL_MTSAFE
return setlocale_null_unlocked (LC_ALL);
# else
char buf[SETLOCALE_NULL_ALL_MAX];
static char resultbuf[SETLOCALE_NULL_ALL_MAX];
if (setlocale_null_r (LC_ALL, buf, sizeof (buf)))
return "C";
strcpy (resultbuf, buf);
return resultbuf;
# endif
}
else
{
# if SETLOCALE_NULL_ONE_MTSAFE
return setlocale_null_unlocked (category);
# else
enum
{
LC_CTYPE_INDEX,
LC_NUMERIC_INDEX,
LC_TIME_INDEX,
LC_COLLATE_INDEX,
LC_MONETARY_INDEX,
LC_MESSAGES_INDEX,
# ifdef LC_PAPER
LC_PAPER_INDEX,
# endif
# ifdef LC_NAME
LC_NAME_INDEX,
# endif
# ifdef LC_ADDRESS
LC_ADDRESS_INDEX,
# endif
# ifdef LC_TELEPHONE
LC_TELEPHONE_INDEX,
# endif
# ifdef LC_MEASUREMENT
LC_MEASUREMENT_INDEX,
# endif
# ifdef LC_IDENTIFICATION
LC_IDENTIFICATION_INDEX,
# endif
LC_INDICES_COUNT
}
i;
char buf[SETLOCALE_NULL_MAX];
static char resultbuf[LC_INDICES_COUNT][SETLOCALE_NULL_MAX];
int err;
err = setlocale_null_r (category, buf, sizeof (buf));
if (err == EINVAL)
return NULL;
if (err)
return "C";
switch (category)
{
case LC_CTYPE: i = LC_CTYPE_INDEX; break;
case LC_NUMERIC: i = LC_NUMERIC_INDEX; break;
case LC_TIME: i = LC_TIME_INDEX; break;
case LC_COLLATE: i = LC_COLLATE_INDEX; break;
case LC_MONETARY: i = LC_MONETARY_INDEX; break;
case LC_MESSAGES: i = LC_MESSAGES_INDEX; break;
# ifdef LC_PAPER
case LC_PAPER: i = LC_PAPER_INDEX; break;
# endif
# ifdef LC_NAME
case LC_NAME: i = LC_NAME_INDEX; break;
# endif
# ifdef LC_ADDRESS
case LC_ADDRESS: i = LC_ADDRESS_INDEX; break;
# endif
# ifdef LC_TELEPHONE
case LC_TELEPHONE: i = LC_TELEPHONE_INDEX; break;
# endif
# ifdef LC_MEASUREMENT
case LC_MEASUREMENT: i = LC_MEASUREMENT_INDEX; break;
# endif
# ifdef LC_IDENTIFICATION
case LC_IDENTIFICATION: i = LC_IDENTIFICATION_INDEX; break;
# endif
default:
/* If you get here, a #ifdef LC_xxx is missing. */
abort ();
}
strcpy (resultbuf[i], buf);
return resultbuf[i];
# endif
}
#endif
}

Some files were not shown because too many files have changed in this diff Show More