Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • phoenix/public/h2o
1 result
Show changes
Commits on Source (607)
Showing
with 631 additions and 117 deletions
......@@ -16,21 +16,25 @@ jobs:
matrix:
include:
- name: default
command: make -f misc/docker-ci/check.mk ALL BUILD_ARGS=-j6 TEST_ENV=TEST_JOBS=4
command: make -f misc/docker-ci/check.mk ALL BUILD_ARGS=-j6 TEST_ENV='TEST_JOBS=4 TEST_PLATFORM=github-actions'
- name: OpenSSL 1.1.0 + Fuzz
command: make -f misc/docker-ci/check.mk ossl1.1.0+fuzz BUILD_ARGS=-j6 TEST_ENV=TEST_JOBS=4
command: make -f misc/docker-ci/check.mk ossl1.1.0+fuzz BUILD_ARGS=-j6 TEST_ENV='TEST_JOBS=4 TEST_PLATFORM=github-actions'
- name: OpenSSL 1.1.1
command: make -f misc/docker-ci/check.mk ossl1.1.1 BUILD_ARGS=-j6 TEST_ENV=TEST_JOBS=4
- name: DTrace + ASan
command: make -f misc/docker-ci/check.mk dtrace+asan BUILD_ARGS=-j6 TEST_ENV=TEST_JOBS=4
command: make -f misc/docker-ci/check.mk ossl1.1.1 BUILD_ARGS=-j6 TEST_ENV='TEST_JOBS=4 TEST_PLATFORM=github-actions'
- name: OpenSSL 3.0 (Ubuntu 22.04 / DTrace)
command: make -f misc/docker-ci/check.mk ossl3.0 BUILD_ARGS=-j6 TEST_ENV='TEST_JOBS=4 TEST_PLATFORM=github-actions'
- name: ASan (Ubuntu 20.04)
command: make -f misc/docker-ci/check.mk asan BUILD_ARGS=-j6 TEST_ENV='TEST_JOBS=4 TEST_PLATFORM=github-actions'
- name: Coverage
command: make -f misc/docker-ci/check.mk coverage BUILD_ARGS=-j6 TEST_ENV='TEST_JOBS=4 TEST_PLATFORM=github-actions'
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
......@@ -43,6 +47,9 @@ jobs:
# restart docker with ipv6 support
cat /etc/docker/daemon.json | perl -pe 's| }|, "ipv6": true, "fixed-cidr-v6": "2001:db8:1::/64" }|' | sudo tee /etc/docker/daemon.json > /dev/null; sudo systemctl restart docker; sleep 10
${{ matrix.command }}
# if there's a summary markdown in the container, show it.
container_id=$(docker container ls -al --format '{{ .ID }}')
docker cp $container_id:/home/ci/summary.md $GITHUB_STEP_SUMMARY || true
# See https://github.com/google/oss-fuzz/tree/master/projects/h2o for details
ossfuzz:
......
......@@ -7,10 +7,10 @@ on:
jobs:
submit:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Populate submodules
run: |
......@@ -27,15 +27,15 @@ jobs:
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
run: |
cat <<EOF > /tmp/deb-src.list
deb-src http://archive.ubuntu.com/ubuntu bionic main restricted
deb-src http://archive.ubuntu.com/ubuntu bionic-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu bionic universe
deb-src http://archive.ubuntu.com/ubuntu bionic-updates universe
deb-src http://archive.ubuntu.com/ubuntu bionic multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic-security main restricted
deb-src http://archive.ubuntu.com/ubuntu bionic-security universe
deb-src http://archive.ubuntu.com/ubuntu bionic-security multiverse
deb-src http://archive.ubuntu.com/ubuntu focal main restricted
deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu focal universe
deb-src http://archive.ubuntu.com/ubuntu focal-updates universe
deb-src http://archive.ubuntu.com/ubuntu focal multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-security main restricted
deb-src http://archive.ubuntu.com/ubuntu focal-security universe
deb-src http://archive.ubuntu.com/ubuntu focal-security multiverse
EOF
sudo cp /tmp/deb-src.list /etc/apt/sources.list.d/
sudo apt-get update
......
......@@ -16,3 +16,4 @@ misc/test-ca/demoCA/newcerts/*.pem
tmp/
/doc/workdir/
include/h2o/gitrev.h
/misc/mruby_config.rb.lock
......@@ -106,17 +106,7 @@ OPTION(BUILD_SHARED_LIBS "whether to build a shared library" OFF)
FIND_PROGRAM(RUBY ruby)
FIND_PROGRAM(BISON bison)
IF (RUBY AND BISON)
# Bundled mruby cannot be built with Ruby 3.x
EXECUTE_PROCESS(
COMMAND "${RUBY}" -e "puts RUBY_VERSION"
OUTPUT_VARIABLE RUBY_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
IF ("${RUBY_VERSION}" VERSION_LESS "3.0.0")
SET(WITH_MRUBY_DEFAULT "ON")
ELSE ()
SET(WITH_MRUBY_DEFAULT "OFF")
ENDIF()
SET(WITH_MRUBY_DEFAULT "ON")
ELSE ()
SET(WITH_MRUBY_DEFAULT "OFF")
ENDIF ()
......@@ -376,6 +366,7 @@ SET(LIB_SOURCE_FILES
deps/picotls/deps/cifra/src/hmac.c
deps/picotls/deps/cifra/src/sha256.c
deps/picotls/lib/certificate_compression.c
deps/picotls/lib/hpke.c
deps/picotls/lib/pembase64.c
deps/picotls/lib/picotls.c
deps/picotls/lib/openssl.c
......@@ -451,6 +442,7 @@ SET(LIB_SOURCE_FILES
lib/handler/status.c
lib/handler/headers_util.c
lib/handler/status/events.c
lib/handler/status/memory.c
lib/handler/status/requests.c
lib/handler/status/ssl.c
lib/handler/http2_debug_state.c
......@@ -756,7 +748,7 @@ IF (WITH_MRUBY)
MRUBY_TOOLCHAIN=${MRUBY_TOOLCHAIN} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} MRUBY_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/misc/mruby_config.rb MRUBY_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/mruby MRUBY_ADDITIONAL_CONFIG=${MRUBY_ADDITIONAL_CONFIG} ruby minirake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mruby
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/mruby/host/lib/libmruby.a"
"${CMAKE_CURRENT_BINARY_DIR}/mruby/host/mrbgems/mruby-onig-regexp/onigmo-6.1.2/.libs/libonigmo.a"
"${CMAKE_CURRENT_BINARY_DIR}/mruby/host/mrbgems/mruby-onig-regexp/onigmo-6.2.0/.libs/libonigmo.a"
)
LIST(APPEND STANDALONE_SOURCE_FILES
lib/handler/mruby.c
......@@ -787,7 +779,7 @@ IF (WITH_MRUBY)
# note: the paths need to be determined before libmruby.flags.mak is generated
TARGET_LINK_LIBRARIES(h2o
"${CMAKE_CURRENT_BINARY_DIR}/mruby/host/lib/libmruby.a"
"${CMAKE_CURRENT_BINARY_DIR}/mruby/host/mrbgems/mruby-onig-regexp/onigmo-6.1.2/.libs/libonigmo.a"
"${CMAKE_CURRENT_BINARY_DIR}/mruby/host/mrbgems/mruby-onig-regexp/onigmo-6.2.0/.libs/libonigmo.a"
"m")
ADD_DEPENDENCIES(h2o mruby)
ENDIF (WITH_MRUBY)
......@@ -883,7 +875,7 @@ GET_FILENAME_COMPONENT(EXTERNALPROJECT_SSL_ROOT_DIR ${OPENSSL_INCLUDE_DIR} PATH)
IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/misc/h2get/CMakeLists.txt AND RUBY AND BISON)
ExternalProject_Add(h2get
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DH2GET_SSL_ROOT_DIR=${EXTERNALPROJECT_SSL_ROOT_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/misc/h2get
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DH2GET_SSL_ROOT_DIR=${EXTERNALPROJECT_SSL_ROOT_DIR} "-DCMAKE_C_FLAGS=-include ${CMAKE_SOURCE_DIR}/include/h2o/openssl_backport.h" ${CMAKE_CURRENT_SOURCE_DIR}/misc/h2get
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/misc/h2get
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/h2get_bin
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
......
......@@ -25,7 +25,7 @@
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define _PICOHASH_BIG_ENDIAN
#endif
#else // ! defined __LITTLE_ENDIAN__
#elif !defined(_WIN32)
#include <endian.h> // machine/endian.h
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define _PICOHASH_BIG_ENDIAN
......@@ -35,11 +35,12 @@
#define PICOHASH_MD5_BLOCK_LENGTH 64
#define PICOHASH_MD5_DIGEST_LENGTH 16
typedef struct {
typedef struct _picohash_md5_ctx_t {
uint_fast32_t lo, hi;
uint_fast32_t a, b, c, d;
unsigned char buffer[64];
uint_fast32_t block[PICOHASH_MD5_DIGEST_LENGTH];
const void *(*_body)(struct _picohash_md5_ctx_t *ctx, const void *data, size_t size);
} _picohash_md5_ctx_t;
static void _picohash_md5_init(_picohash_md5_ctx_t *ctx);
......@@ -268,6 +269,8 @@ inline void _picohash_md5_init(_picohash_md5_ctx_t *ctx)
ctx->lo = 0;
ctx->hi = 0;
ctx->_body = _picohash_md5_body;
}
inline void _picohash_md5_update(_picohash_md5_ctx_t *ctx, const void *data, size_t size)
......@@ -293,11 +296,11 @@ inline void _picohash_md5_update(_picohash_md5_ctx_t *ctx, const void *data, siz
memcpy(&ctx->buffer[used], data, free);
data = (const unsigned char *)data + free;
size -= free;
_picohash_md5_body(ctx, ctx->buffer, 64);
ctx->_body(ctx, ctx->buffer, 64);
}
if (size >= 64) {
data = _picohash_md5_body(ctx, data, size & ~(unsigned long)0x3f);
data = ctx->_body(ctx, data, size & ~(unsigned long)0x3f);
size &= 0x3f;
}
......@@ -317,7 +320,7 @@ inline void _picohash_md5_final(_picohash_md5_ctx_t *ctx, void *_digest)
if (free < 8) {
memset(&ctx->buffer[used], 0, free);
_picohash_md5_body(ctx, ctx->buffer, 64);
ctx->_body(ctx, ctx->buffer, 64);
used = 0;
free = 64;
}
......@@ -334,7 +337,7 @@ inline void _picohash_md5_final(_picohash_md5_ctx_t *ctx, void *_digest)
ctx->buffer[62] = ctx->hi >> 16;
ctx->buffer[63] = ctx->hi >> 24;
_picohash_md5_body(ctx, ctx->buffer, 64);
ctx->_body(ctx, ctx->buffer, 64);
digest[0] = ctx->a;
digest[1] = ctx->a >> 8;
......
......@@ -183,8 +183,8 @@ mrb_dir_chdir(mrb_state *mrb, mrb_value klass)
mrb_value
mrb_dir_chroot(mrb_state *mrb, mrb_value self)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__android__)
mrb_raise(mrb, E_NOTIMP_ERROR, "chroot() unreliable on Win platforms");
#if defined(_WIN32) || defined(_WIN64) || defined(__ANDROID__)
mrb_raise(mrb, E_NOTIMP_ERROR, "chroot() unreliable on your system");
return mrb_fixnum_value(0);
#else
mrb_value spath;
......@@ -238,8 +238,8 @@ mrb_dir_rewind(mrb_state *mrb, mrb_value self)
mrb_value
mrb_dir_seek(mrb_state *mrb, mrb_value self)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__android__)
mrb_raise(mrb, E_NOTIMP_ERROR, "dirseek() unreliable on Win platforms");
#if defined(_WIN32) || defined(_WIN64) || defined(__ANDROID__)
mrb_raise(mrb, E_NOTIMP_ERROR, "dirseek() unreliable on your system");
return self;
#else
struct mrb_dir *mdir;
......@@ -259,8 +259,8 @@ mrb_dir_seek(mrb_state *mrb, mrb_value self)
mrb_value
mrb_dir_tell(mrb_state *mrb, mrb_value self)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__android__)
mrb_raise(mrb, E_NOTIMP_ERROR, "dirtell() unreliable on Win platforms");
#if defined(_WIN32) || defined(_WIN64) || defined(__ANDROID__)
mrb_raise(mrb, E_NOTIMP_ERROR, "dirtell() unreliable on your system");
return mrb_fixnum_value(0);
#else
struct mrb_dir *mdir;
......
......@@ -4,10 +4,13 @@ mruby-env
mruby-env provides "ENV" object, which is a hash-like accessor
for environment variables.
- https://docs.ruby-lang.org/en/trunk/ENV.html (en)
- https://docs.ruby-lang.org/ja/latest/class/ENV.html (ja)
### Methods
```
[] []= clear delete has_key? include? inspect key? keys
[] []= clear delete fetch has_key? include? inspect key? keys
member? size store to_a to_hash to_s values
```
......@@ -32,21 +35,21 @@ Prerequisites:
Copyright (c) 2012 Internet Initiative Japan Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
def gem_config(conf)
conf.gem :core => "mruby-time"
conf.gem '../'
end
MRuby::Build.new do |conf|
toolchain :gcc
conf.enable_test
if ENV['DISABLE_PRESYM'] == 'true'
conf.disable_presym
end
gem_config(conf)
end
if ENV['TARGET'] == 'windows-x86_64'
MRuby::CrossBuild.new('windows-x86_64') do |conf|
toolchain :gcc
conf.cc.command = 'x86_64-w64-mingw32-gcc'
conf.linker.command = 'x86_64-w64-mingw32-gcc'
conf.cxx.command = 'x86_64-w64-mingw32-g++'
conf.archiver.command = 'x86_64-w64-mingw32-gcc-ar'
conf.exts do |exts|
exts.object = '.obj'
exts.executable = '.exe'
exts.library = '.lib'
end
conf.build_target = 'x86_64-pc-linux-gnu'
conf.host_target = 'x86_64-w64-mingw32'
gem_config(conf)
end
end
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
ubuntu-1804-gcc:
strategy:
matrix:
mruby-version:
- 2.1.2
- 2.0.1
include:
- mruby-version: 3.0.0
disable-presym: 'true'
- mruby-version: 3.0.0
disable-presym: 'false'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1.59.1
with:
ruby-version: '2.7'
- name: Build and test
env:
CC: gcc
CXX: g++
MRUBY_VERSION: ${{ matrix.mruby-version }}
DISABLE_PRESYM: ${{ matrix.disable-presym }}
run: rake test
ubuntu-1804-clang:
strategy:
matrix:
mruby-version:
- 2.1.2
- 2.0.1
include:
- mruby-version: 3.0.0
disable-presym: 'true'
- mruby-version: 3.0.0
disable-presym: 'false'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1.59.1
with:
ruby-version: '2.7'
- name: Build and test
env:
CC: clang
CXX: clang++
MRUBY_VERSION: ${{ matrix.mruby-version }}
DISABLE_PRESYM: ${{ matrix.disable-presym }}
run: rake test
ubuntu-1804-mingw:
strategy:
matrix:
mruby-version:
- 2.1.2
- 2.0.1
include:
- mruby-version: 3.0.0
disable-presym: 'true'
- mruby-version: 3.0.0
disable-presym: 'false'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1.59.1
with:
ruby-version: '2.7'
- name: apt
run: sudo apt install mingw-w64
- name: Build and test
env:
TARGET: windows-x86_64
MRUBY_VERSION: ${{ matrix.mruby-version }}
DISABLE_PRESYM: ${{ matrix.disable-presym }}
run: rake test
windows-mingw:
strategy:
matrix:
mruby-version:
- 2.1.2
- 2.0.1
include:
- mruby-version: 3.0.0
disable-presym: 'true'
- mruby-version: 3.0.0
disable-presym: 'false'
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1.59.1
with:
ruby-version: '2.7'
- name: Build and test
env:
CFLAGS: -g -O1 -Wall -Wundef
MRUBY_VERSION: ${{ matrix.mruby-version }}
DISABLE_PRESYM: ${{ matrix.disable-presym }}
run: rake test
......@@ -3,3 +3,5 @@ autom4te.cache/
*.log
config.status
config.h
*.lock
/mruby-*
language: c
compiler:
- gcc
- clang
before_install:
- sudo apt-get -qq update
install:
- sudo apt-get -qq install rake bison git gperf
before_script:
- cd ../
- git clone https://github.com/mruby/mruby.git
- cd mruby
- cp -fp ../mruby-file-stat/.travis_build_config.rb build_config.rb
script:
- ruby minirake all test
# mruby-file-stat
[![Build Status](https://travis-ci.org/ksss/mruby-file-stat.svg?branch=master)](https://travis-ci.org/ksss/mruby-file-stat)
[![Build status](https://ci.appveyor.com/api/projects/status/04am84uda2cj49n3/branch/master?svg=true)](https://ci.appveyor.com/project/ksss/mruby-file-stat/branch/master)
[![CI](https://github.com/ksss/mruby-file-stat/workflows/CI/badge.svg)](https://github.com/ksss/mruby-file-stat/actions)
**File::Stat** class in mruby
......
mruby_version = ENV["MRUBY_VERSION"] || 'master'
mruby_dir = "mruby-#{mruby_version}"
file 'mruby-head' do
sh "git clone --depth 1 --no-single-branch git://github.com/mruby/mruby.git"
sh "mv mruby mruby-head"
end
file mruby_dir => 'mruby-head' do
sh "cp -a mruby-head #{mruby_dir}"
cd mruby_dir do
sh "git checkout #{mruby_version}"
end
end
file "#{mruby_dir}/ci_build_config.rb" => [mruby_dir, ".ci_build_config.rb"] do
sh "cp #{File.expand_path(".ci_build_config.rb")} #{mruby_dir}/ci_build_config.rb"
end
desc "run test with mruby"
task :test => "#{mruby_dir}/ci_build_config.rb" do
cd mruby_dir do
sh "rake -E 'STDOUT.sync=true' test all MRUBY_CONFIG=ci_build_config.rb"
end
end
---
version: "#{build}"
environment:
MRUBY_CONFIG: "C:/projects/mruby-file-stat/.travis_build_config.rb"
matrix:
- Compiler: mingw
install:
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
- set PATH=C:\MinGW\bin;C:\MinGW\msys\1.0\bin;%PATH%
- ruby --version
- gem --version
- gcc --version
- gem install rake --force
- cd ..
- git clone --depth 1 https://github.com/mruby/mruby.git
- cd mruby
build_script:
- ruby minirake all test --trace --verbose
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if your system has a working `getgroups' function. */
/* Define to 1 if you have the `getgroups' function. */
#undef HAVE_GETGROUPS
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `lstat' function. */
#undef HAVE_LSTAT
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if `st_atim' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_ATIM
/* Define to 1 if `st_atimensec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_ATIMENSEC
/* Define to 1 if `st_atimespec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_ATIMESPEC
/* Define to 1 if `st_birthtimespec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC
/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
/* Define to 1 if `st_blocks' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLOCKS
/* Define to 1 if `st_ctim' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_CTIM
/* Define to 1 if `st_ctimensec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_CTIMENSEC
/* Define to 1 if `st_ctimespec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_CTIMESPEC
/* Define to 1 if `st_mtim' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_MTIM
/* Define to 1 if `st_mtimensec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_MTIMENSEC
/* Define to 1 if `st_mtimespec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_MTIMESPEC
/* Define to 1 if `st_rdev' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
/* Define to 1 if `st_birthtimespec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
#undef HAVE_SYS_SYSMACROS_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
......@@ -1692,6 +1692,93 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
# the include files in INCLUDES and setting the cache variable VAR
# accordingly.
ac_fn_c_check_header_mongrel ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if eval \${$3+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
$as_echo_n "checking $2 usability... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_header_compiler=yes
else
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
$as_echo_n "checking $2 presence... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <$2>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
ac_header_preproc=yes
else
ac_header_preproc=no
fi
rm -f conftest.err conftest.i conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
yes:no: )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
;;
no:yes:* )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=\$ac_header_compiler"
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_mongrel
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
......@@ -3265,6 +3352,97 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_atim" "ac_cv_member_struct_stat_st_atim" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_atim" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_ATIM 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec" "ac_cv_member_struct_stat_st_atimespec" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_atimespec" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_ATIMESPEC 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_atimensec" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_ATIMENSEC 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_MTIM 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimespec" "ac_cv_member_struct_stat_st_mtimespec" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_mtimespec" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_MTIMESPEC 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimensec" "ac_cv_member_struct_stat_st_mtimensec" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_mtimensec" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_ctim" "ac_cv_member_struct_stat_st_ctim" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_ctim" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_CTIM 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_ctimespec" "ac_cv_member_struct_stat_st_ctimespec" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_ctimespec" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_CTIMESPEC 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_ctimensec" "ac_cv_member_struct_stat_st_ctimensec" "$ac_includes_default"
if test "x$ac_cv_member_struct_stat_st_ctimensec" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_STAT_ST_CTIMENSEC 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtimespec" "ac_cv_member_struct_stat_st_birthtimespec" "$ac_includes_default"
......@@ -3301,6 +3479,19 @@ fi
done
for ac_header in sys/sysmacros.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_sysmacros_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SYS_SYSMACROS_H 1
_ACEOF
fi
done
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
......
......@@ -12,9 +12,21 @@ AC_CONFIG_HEADERS([config.h])
AC_CHECK_MEMBERS([struct stat.st_blksize])
AC_CHECK_MEMBERS([struct stat.st_blocks])
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_CHECK_MEMBERS([struct stat.st_atim])
AC_CHECK_MEMBERS([struct stat.st_atimespec])
AC_CHECK_MEMBERS([struct stat.st_atimensec])
AC_CHECK_MEMBERS([struct stat.st_mtim])
AC_CHECK_MEMBERS([struct stat.st_mtimespec])
AC_CHECK_MEMBERS([struct stat.st_mtimensec])
AC_CHECK_MEMBERS([struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_ctimespec])
AC_CHECK_MEMBERS([struct stat.st_ctimensec])
AC_CHECK_MEMBERS([struct stat.st_birthtimespec])
AC_CHECK_FUNCS(getgroups)
AC_CHECK_FUNCS(lstat)
AC_CHECK_HEADERS(sys/sysmacros.h)
AC_OUTPUT
......@@ -19,11 +19,18 @@ MRuby::Gem::Specification.new('mruby-file-stat') do |spec|
FileUtils.touch "#{build_dir}/config.h", :verbose => true
else
_pp './configure', dir
system env, "#{dir}/configure"
host = ''
if build.kind_of?(MRuby::CrossBuild) && build.host_target
host = "--host #{build.host_target}"
end
system env, "#{dir}/configure #{host}"
end
end
end
file "#{build_dir}/src/file-stat.o" => [ "#{dir}/src/file-stat.c", config ]
# build hook
file "#{dir}/src/file-stat.c" => config
task :clean do
FileUtils.rm_f config, :verbose => true
end
......
......@@ -33,8 +33,10 @@ class File
'mtime' => mtime,
'ctime' => ctime,
}
if respond_to? :birthtime
begin
stats['birthtime'] = birthtime
rescue NotImplementedError
# skip
end
"#<#{self.class.to_s} #{stats.map{|k, v| "#{k}=#{v}"}.join(', ')}>"
......
......@@ -2,12 +2,19 @@
* original is https://github.com/ruby/ruby/blob/trunk/file.c
*/
#include "config.h"
#include "mruby.h"
#include "mruby/string.h"
#include "mruby/data.h"
#include "mruby/error.h"
#include "mruby/class.h"
#include <stdlib.h>
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
......@@ -94,8 +101,6 @@
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#include "config.h"
#define STAT(p,s) stat(p,s)
#ifdef HAVE_LSTAT
# define LSTAT(p,s) lstat(p,s)
......@@ -162,8 +167,16 @@ file_s_lstat(mrb_state *mrb, mrb_value klass)
tmp = mrb_convert_type(mrb, fname, MRB_TT_STRING, "String", "to_str");
}
path = mrb_str_to_cstr(mrb, tmp);
if (LSTAT(path, &st) == -1) {
mrb_sys_fail(mrb, path);
{
char *locale_path;
int lstat_result;
locale_path = mrb_locale_from_utf8(path, -1);
lstat_result = LSTAT(locale_path, &st);
mrb_locale_free(locale_path);
if (lstat_result == -1) {
mrb_sys_fail(mrb, path);
}
}
file_class = mrb_class_ptr(klass);
......@@ -188,8 +201,16 @@ stat_initialize(mrb_state *mrb, mrb_value self)
tmp = mrb_convert_type(mrb, fname, MRB_TT_STRING, "String", "to_str");
}
path = mrb_str_to_cstr(mrb, tmp);
if (STAT(path, &st) == -1) {
mrb_sys_fail(mrb, path);
{
char *locale_path;
int stat_result;
locale_path = mrb_locale_from_utf8(path, -1);
stat_result = STAT(locale_path, &st);
mrb_locale_free(locale_path);
if (stat_result == -1) {
mrb_sys_fail(mrb, path);
}
}
ptr = (struct stat *)DATA_PTR(self);
......@@ -246,7 +267,12 @@ static mrb_value
mrb_ll2num(mrb_state *mrb, long long t)
{
if (MRB_INT_MIN <= t && t <= MRB_INT_MAX) {
/* mruby is 2b188ed8a191257f23ddf6f8a27bf1d3964587ed or later. */
#ifdef SET_FIXNUM_VALUE
return mrb_int_value(mrb, (mrb_int)t);
#else
return mrb_fixnum_value((mrb_int)t);
#endif
} else {
return mrb_float_value(mrb, (mrb_float)t);
}
......@@ -362,39 +388,95 @@ stat_rdev_minor(mrb_state *mrb, mrb_value self)
}
static mrb_value
time_at_with_sec(mrb_state *mrb, long long sec)
time_at_with_sec_nsec(mrb_state *mrb, time_t sec, long nsec)
{
return mrb_funcall(mrb, mrb_obj_value(mrb_class_get(mrb, "Time")), "at", 1, mrb_ll2num(mrb, sec));
return mrb_funcall(mrb, mrb_obj_value(mrb_class_get(mrb, "Time")), "at", 2, mrb_ll2num(mrb, sec), mrb_ll2num(mrb, nsec / 1000));
}
static struct timespec
stat_atimespec(const struct stat *st)
{
struct timespec ts;
ts.tv_sec = st->st_atime;
#if defined(HAVE_STRUCT_STAT_ST_ATIM)
ts.tv_nsec = st->st_atim.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
ts.tv_nsec = st->st_atimespec.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC)
ts.tv_nsec = (long)st->st_atimensec;
#else
ts.tv_nsec = 0;
#endif
return ts;
}
static mrb_value
stat_atime(mrb_state *mrb, mrb_value self)
{
return time_at_with_sec(mrb, get_stat(mrb, self)->st_atime);
struct timespec ts = stat_atimespec(get_stat(mrb, self));
return time_at_with_sec_nsec(mrb, ts.tv_sec, ts.tv_nsec);
}
static struct timespec
stat_mtimespec(const struct stat *st)
{
struct timespec ts;
ts.tv_sec = st->st_mtime;
#if defined(HAVE_STRUCT_STAT_ST_MTIM)
ts.tv_nsec = st->st_mtim.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
ts.tv_nsec = st->st_mtimespec.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
ts.tv_nsec = (long)st->st_mtimensec;
#else
ts.tv_nsec = 0;
#endif
return ts;
}
static mrb_value
stat_mtime(mrb_state *mrb, mrb_value self)
{
return time_at_with_sec(mrb, get_stat(mrb, self)->st_mtime);
struct timespec ts = stat_mtimespec(get_stat(mrb, self));
return time_at_with_sec_nsec(mrb, ts.tv_sec, ts.tv_nsec);
}
static struct timespec
stat_ctimespec(const struct stat *st)
{
struct timespec ts;
ts.tv_sec = st->st_ctime;
#if defined(HAVE_STRUCT_STAT_ST_CTIM)
ts.tv_nsec = st->st_ctim.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_CTIMESPEC)
ts.tv_nsec = st->st_ctimespec.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_CTIMENSEC)
ts.tv_nsec = (long)st->st_ctimensec;
#else
ts.tv_nsec = 0;
#endif
return ts;
}
static mrb_value
stat_ctime(mrb_state *mrb, mrb_value self)
{
return time_at_with_sec(mrb, get_stat(mrb, self)->st_ctime);
struct timespec ts = stat_ctimespec(get_stat(mrb, self));
return time_at_with_sec_nsec(mrb, ts.tv_sec, ts.tv_nsec);
}
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC)
static mrb_value
stat_birthtime(mrb_state *mrb, mrb_value self)
{
return time_at_with_sec(mrb, get_stat(mrb, self)->st_birthtimespec.tv_sec);
struct stat *st = get_stat(mrb, self);
const struct timespec *ts = &st->st_birthtimespec;
return time_at_with_sec_nsec(mrb, ts->tv_sec, ts->tv_nsec);
}
# define HAVE_METHOD_BIRTHTIME 1
#elif defined(_WIN32)
# define stat_birthtime stat_ctime
# define HAVE_METHOD_BIRTHTIME 1
#else
# define stat_birthtime mrb_notimplement_m
#endif
static mrb_value
......@@ -596,9 +678,9 @@ stat_writable_real_p(mrb_state *mrb, mrb_value self)
static mrb_value
stat_world_writable_p(mrb_state *mrb, mrb_value self)
{
#ifdef S_IROTH
#ifdef S_IWOTH
struct stat *st = get_stat(mrb, self);
if ((st->st_mode & (S_IROTH)) == S_IROTH) {
if ((st->st_mode & (S_IWOTH)) == S_IWOTH) {
return mrb_fixnum_value(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
}
else {
......@@ -833,9 +915,7 @@ mrb_mruby_file_stat_gem_init(mrb_state* mrb)
mrb_define_method(mrb, stat, "atime", stat_atime, MRB_ARGS_NONE());
mrb_define_method(mrb, stat, "mtime", stat_mtime, MRB_ARGS_NONE());
mrb_define_method(mrb, stat, "ctime", stat_ctime, MRB_ARGS_NONE());
#ifdef HAVE_METHOD_BIRTHTIME
mrb_define_method(mrb, stat, "birthtime", stat_birthtime, MRB_ARGS_NONE());
#endif
mrb_define_method(mrb, stat, "size", stat_size, MRB_ARGS_NONE());
mrb_define_method(mrb, stat, "blksize", stat_blksize, MRB_ARGS_NONE());
mrb_define_method(mrb, stat, "blocks", stat_blocks, MRB_ARGS_NONE());
......