etc 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/etc/etc.c +31 -31
- data/ext/etc/extconf.rb +1 -4
- data/test/etc/test_etc.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c60b51f5cf5237e306c210a1912bd9feb1c7a75bc7bd5d87b2b2ba2c6e82c01
|
4
|
+
data.tar.gz: fc93add02caa73345c5b0ed48209a1307275189447ab95f1078df8f5ee362dc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cb34202dcb7a18d708b07967d2db958b27e0cc51c675746530adbf4af07b24b9393b3e0ecb91d4133e2a179c2023fd0c8503d9faa992b5a398c92b2b9699f3f
|
7
|
+
data.tar.gz: 834167d66f21aac210b0ffe83093b1252245be3b1e11b15dd2879d409f353c6537a67b48107f56ba516873e2a0976d5f64a9e15e2bb8c8560ef71f019c70aaee
|
data/ext/etc/etc.c
CHANGED
@@ -52,7 +52,7 @@ char *getenv();
|
|
52
52
|
#endif
|
53
53
|
char *getlogin();
|
54
54
|
|
55
|
-
#define RUBY_ETC_VERSION "1.
|
55
|
+
#define RUBY_ETC_VERSION "1.3.0"
|
56
56
|
|
57
57
|
#ifdef HAVE_RB_DEPRECATE_CONSTANT
|
58
58
|
void rb_deprecate_constant(VALUE mod, const char *name);
|
@@ -62,22 +62,21 @@ void rb_deprecate_constant(VALUE mod, const char *name);
|
|
62
62
|
|
63
63
|
#include "constdefs.h"
|
64
64
|
|
65
|
-
#ifdef
|
66
|
-
#include "ruby/
|
65
|
+
#ifdef HAVE_RUBY_ATOMIC_H
|
66
|
+
# include "ruby/atomic.h"
|
67
67
|
#else
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
68
|
+
typedef int rb_atomic_t;
|
69
|
+
# define RUBY_ATOMIC_CAS(var, oldval, newval) \
|
70
|
+
((var) == (oldval) ? ((var) = (newval), (oldval)) : (var))
|
71
|
+
# define RUBY_ATOMIC_EXCHANGE(var, newval) \
|
72
|
+
atomic_exchange(&var, newval)
|
73
|
+
static inline rb_atomic_t
|
74
|
+
atomic_exchange(volatile rb_atomic_t *var, rb_atomic_t newval)
|
75
|
+
{
|
76
|
+
rb_atomic_t oldval = *var;
|
77
|
+
*var = newval;
|
78
|
+
return oldval;
|
79
79
|
}
|
80
|
-
#define rb_native_mutex_initialize rb_native_mutex_unlock
|
81
80
|
#endif
|
82
81
|
|
83
82
|
/* call-seq:
|
@@ -258,12 +257,14 @@ etc_getpwnam(VALUE obj, VALUE nam)
|
|
258
257
|
}
|
259
258
|
|
260
259
|
#ifdef HAVE_GETPWENT
|
261
|
-
static
|
260
|
+
static rb_atomic_t passwd_blocking;
|
262
261
|
static VALUE
|
263
262
|
passwd_ensure(VALUE _)
|
264
263
|
{
|
265
264
|
endpwent();
|
266
|
-
|
265
|
+
if (RUBY_ATOMIC_EXCHANGE(passwd_blocking, 0) != 1) {
|
266
|
+
rb_raise(rb_eRuntimeError, "unexpected passwd_blocking");
|
267
|
+
}
|
267
268
|
return Qnil;
|
268
269
|
}
|
269
270
|
|
@@ -282,7 +283,7 @@ passwd_iterate(VALUE _)
|
|
282
283
|
static void
|
283
284
|
each_passwd(void)
|
284
285
|
{
|
285
|
-
if (
|
286
|
+
if (RUBY_ATOMIC_CAS(passwd_blocking, 0, 1)) {
|
286
287
|
rb_raise(rb_eRuntimeError, "parallel passwd iteration");
|
287
288
|
}
|
288
289
|
rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
|
@@ -500,12 +501,14 @@ etc_getgrnam(VALUE obj, VALUE nam)
|
|
500
501
|
}
|
501
502
|
|
502
503
|
#ifdef HAVE_GETGRENT
|
503
|
-
static
|
504
|
+
static rb_atomic_t group_blocking;
|
504
505
|
static VALUE
|
505
506
|
group_ensure(VALUE _)
|
506
507
|
{
|
507
508
|
endgrent();
|
508
|
-
|
509
|
+
if (RUBY_ATOMIC_EXCHANGE(group_blocking, 0) != 1) {
|
510
|
+
rb_raise(rb_eRuntimeError, "unexpected group_blocking");
|
511
|
+
}
|
509
512
|
return Qnil;
|
510
513
|
}
|
511
514
|
|
@@ -525,7 +528,7 @@ group_iterate(VALUE _)
|
|
525
528
|
static void
|
526
529
|
each_group(void)
|
527
530
|
{
|
528
|
-
if (
|
531
|
+
if (RUBY_ATOMIC_CAS(group_blocking, 0, 1)) {
|
529
532
|
rb_raise(rb_eRuntimeError, "parallel group iteration");
|
530
533
|
}
|
531
534
|
rb_ensure(group_iterate, 0, group_ensure, 0);
|
@@ -954,11 +957,13 @@ io_pathconf(VALUE io, VALUE arg)
|
|
954
957
|
static int
|
955
958
|
etc_nprocessors_affin(void)
|
956
959
|
{
|
957
|
-
cpu_set_t *cpuset;
|
960
|
+
cpu_set_t *cpuset, cpuset_buff[1024 / sizeof(cpu_set_t)];
|
958
961
|
size_t size;
|
959
962
|
int ret;
|
960
963
|
int n;
|
961
964
|
|
965
|
+
CPU_ZERO_S(sizeof(cpuset_buff), cpuset_buff);
|
966
|
+
|
962
967
|
/*
|
963
968
|
* XXX:
|
964
969
|
* man page says CPU_ALLOC takes number of cpus. But it is not accurate
|
@@ -977,13 +982,12 @@ etc_nprocessors_affin(void)
|
|
977
982
|
*/
|
978
983
|
for (n=64; n <= 16384; n *= 2) {
|
979
984
|
size = CPU_ALLOC_SIZE(n);
|
980
|
-
if (size >=
|
985
|
+
if (size >= sizeof(cpuset_buff)) {
|
981
986
|
cpuset = xcalloc(1, size);
|
982
987
|
if (!cpuset)
|
983
988
|
return -1;
|
984
989
|
} else {
|
985
|
-
cpuset =
|
986
|
-
CPU_ZERO_S(size, cpuset);
|
990
|
+
cpuset = cpuset_buff;
|
987
991
|
}
|
988
992
|
|
989
993
|
ret = sched_getaffinity(0, size, cpuset);
|
@@ -992,10 +996,10 @@ etc_nprocessors_affin(void)
|
|
992
996
|
ret = CPU_COUNT_S(size, cpuset);
|
993
997
|
}
|
994
998
|
|
995
|
-
if (size >=
|
999
|
+
if (size >= sizeof(cpuset_buff)) {
|
996
1000
|
xfree(cpuset);
|
997
1001
|
}
|
998
|
-
if (ret > 0) {
|
1002
|
+
if (ret > 0 || errno != EINVAL) {
|
999
1003
|
return ret;
|
1000
1004
|
}
|
1001
1005
|
}
|
@@ -1199,11 +1203,7 @@ Init_etc(void)
|
|
1199
1203
|
rb_deprecate_constant(rb_cStruct, "Passwd");
|
1200
1204
|
rb_extend_object(sPasswd, rb_mEnumerable);
|
1201
1205
|
rb_define_singleton_method(sPasswd, "each", etc_each_passwd, 0);
|
1202
|
-
#ifdef HAVE_GETPWENT
|
1203
|
-
rb_native_mutex_initialize(&passwd_blocking);
|
1204
|
-
#endif
|
1205
1206
|
#ifdef HAVE_GETGRENT
|
1206
|
-
rb_native_mutex_initialize(&group_blocking);
|
1207
1207
|
sGroup = rb_struct_define_under(mEtc, "Group", "name",
|
1208
1208
|
#ifdef HAVE_STRUCT_GROUP_GR_PASSWD
|
1209
1209
|
"passwd",
|
data/ext/etc/extconf.rb
CHANGED
@@ -47,10 +47,7 @@ if !File.exist?("#{srcdir}/depend")
|
|
47
47
|
%x[#{RbConfig.ruby} #{srcdir}/mkconstants.rb -o #{srcdir}/constdefs.h]
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
"void rb_deprecate_constant(VALUE, const char *);",
|
52
|
-
]
|
53
|
-
have_func('rb_deprecate_constant(Qnil, "None")', [decl])
|
50
|
+
have_func('rb_deprecate_constant(Qnil, "None")')
|
54
51
|
|
55
52
|
$distcleanfiles << "constdefs.h"
|
56
53
|
|
data/test/etc/test_etc.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.3.0.dev
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Provides access to information typically stored in UNIX /etc directory.
|