#define pp_list Perl_pp_list
#define pp_listen Perl_pp_listen
#define pp_localtime Perl_pp_localtime
+#define pp_lock Perl_pp_lock
#define pp_log Perl_pp_log
#define pp_lslice Perl_pp_lslice
#define pp_lstat Perl_pp_lstat
pp_list
pp_listen
pp_localtime
+pp_lock
pp_log
pp_lslice
pp_lstat
#define KEY_listen 118
#define KEY_local 119
#define KEY_localtime 120
-#define KEY_log 121
-#define KEY_lstat 122
-#define KEY_lt 123
-#define KEY_m 124
-#define KEY_map 125
-#define KEY_mkdir 126
-#define KEY_msgctl 127
-#define KEY_msgget 128
-#define KEY_msgrcv 129
-#define KEY_msgsnd 130
-#define KEY_my 131
-#define KEY_ne 132
-#define KEY_next 133
-#define KEY_no 134
-#define KEY_not 135
-#define KEY_oct 136
-#define KEY_open 137
-#define KEY_opendir 138
-#define KEY_or 139
-#define KEY_ord 140
-#define KEY_pack 141
-#define KEY_package 142
-#define KEY_pipe 143
-#define KEY_pop 144
-#define KEY_pos 145
-#define KEY_print 146
-#define KEY_printf 147
-#define KEY_prototype 148
-#define KEY_push 149
-#define KEY_q 150
-#define KEY_qq 151
-#define KEY_quotemeta 152
-#define KEY_qw 153
-#define KEY_qx 154
-#define KEY_rand 155
-#define KEY_read 156
-#define KEY_readdir 157
-#define KEY_readline 158
-#define KEY_readlink 159
-#define KEY_readpipe 160
-#define KEY_recv 161
-#define KEY_redo 162
-#define KEY_ref 163
-#define KEY_rename 164
-#define KEY_require 165
-#define KEY_reset 166
-#define KEY_return 167
-#define KEY_reverse 168
-#define KEY_rewinddir 169
-#define KEY_rindex 170
-#define KEY_rmdir 171
-#define KEY_s 172
-#define KEY_scalar 173
-#define KEY_seek 174
-#define KEY_seekdir 175
-#define KEY_select 176
-#define KEY_semctl 177
-#define KEY_semget 178
-#define KEY_semop 179
-#define KEY_send 180
-#define KEY_setgrent 181
-#define KEY_sethostent 182
-#define KEY_setnetent 183
-#define KEY_setpgrp 184
-#define KEY_setpriority 185
-#define KEY_setprotoent 186
-#define KEY_setpwent 187
-#define KEY_setservent 188
-#define KEY_setsockopt 189
-#define KEY_shift 190
-#define KEY_shmctl 191
-#define KEY_shmget 192
-#define KEY_shmread 193
-#define KEY_shmwrite 194
-#define KEY_shutdown 195
-#define KEY_sin 196
-#define KEY_sleep 197
-#define KEY_socket 198
-#define KEY_socketpair 199
-#define KEY_sort 200
-#define KEY_splice 201
-#define KEY_split 202
-#define KEY_sprintf 203
-#define KEY_sqrt 204
-#define KEY_srand 205
-#define KEY_stat 206
-#define KEY_study 207
-#define KEY_sub 208
-#define KEY_substr 209
-#define KEY_symlink 210
-#define KEY_syscall 211
-#define KEY_sysopen 212
-#define KEY_sysread 213
-#define KEY_sysseek 214
-#define KEY_system 215
-#define KEY_syswrite 216
-#define KEY_tell 217
-#define KEY_telldir 218
-#define KEY_tie 219
-#define KEY_tied 220
-#define KEY_time 221
-#define KEY_times 222
-#define KEY_tr 223
-#define KEY_truncate 224
-#define KEY_uc 225
-#define KEY_ucfirst 226
-#define KEY_umask 227
-#define KEY_undef 228
-#define KEY_unless 229
-#define KEY_unlink 230
-#define KEY_unpack 231
-#define KEY_unshift 232
-#define KEY_untie 233
-#define KEY_until 234
-#define KEY_use 235
-#define KEY_utime 236
-#define KEY_values 237
-#define KEY_vec 238
-#define KEY_wait 239
-#define KEY_waitpid 240
-#define KEY_wantarray 241
-#define KEY_warn 242
-#define KEY_while 243
-#define KEY_write 244
-#define KEY_x 245
-#define KEY_xor 246
-#define KEY_y 247
+#define KEY_lock 121
+#define KEY_log 122
+#define KEY_lstat 123
+#define KEY_lt 124
+#define KEY_m 125
+#define KEY_map 126
+#define KEY_mkdir 127
+#define KEY_msgctl 128
+#define KEY_msgget 129
+#define KEY_msgrcv 130
+#define KEY_msgsnd 131
+#define KEY_my 132
+#define KEY_ne 133
+#define KEY_next 134
+#define KEY_no 135
+#define KEY_not 136
+#define KEY_oct 137
+#define KEY_open 138
+#define KEY_opendir 139
+#define KEY_or 140
+#define KEY_ord 141
+#define KEY_pack 142
+#define KEY_package 143
+#define KEY_pipe 144
+#define KEY_pop 145
+#define KEY_pos 146
+#define KEY_print 147
+#define KEY_printf 148
+#define KEY_prototype 149
+#define KEY_push 150
+#define KEY_q 151
+#define KEY_qq 152
+#define KEY_quotemeta 153
+#define KEY_qw 154
+#define KEY_qx 155
+#define KEY_rand 156
+#define KEY_read 157
+#define KEY_readdir 158
+#define KEY_readline 159
+#define KEY_readlink 160
+#define KEY_readpipe 161
+#define KEY_recv 162
+#define KEY_redo 163
+#define KEY_ref 164
+#define KEY_rename 165
+#define KEY_require 166
+#define KEY_reset 167
+#define KEY_return 168
+#define KEY_reverse 169
+#define KEY_rewinddir 170
+#define KEY_rindex 171
+#define KEY_rmdir 172
+#define KEY_s 173
+#define KEY_scalar 174
+#define KEY_seek 175
+#define KEY_seekdir 176
+#define KEY_select 177
+#define KEY_semctl 178
+#define KEY_semget 179
+#define KEY_semop 180
+#define KEY_send 181
+#define KEY_setgrent 182
+#define KEY_sethostent 183
+#define KEY_setnetent 184
+#define KEY_setpgrp 185
+#define KEY_setpriority 186
+#define KEY_setprotoent 187
+#define KEY_setpwent 188
+#define KEY_setservent 189
+#define KEY_setsockopt 190
+#define KEY_shift 191
+#define KEY_shmctl 192
+#define KEY_shmget 193
+#define KEY_shmread 194
+#define KEY_shmwrite 195
+#define KEY_shutdown 196
+#define KEY_sin 197
+#define KEY_sleep 198
+#define KEY_socket 199
+#define KEY_socketpair 200
+#define KEY_sort 201
+#define KEY_splice 202
+#define KEY_split 203
+#define KEY_sprintf 204
+#define KEY_sqrt 205
+#define KEY_srand 206
+#define KEY_stat 207
+#define KEY_study 208
+#define KEY_sub 209
+#define KEY_substr 210
+#define KEY_symlink 211
+#define KEY_syscall 212
+#define KEY_sysopen 213
+#define KEY_sysread 214
+#define KEY_sysseek 215
+#define KEY_system 216
+#define KEY_syswrite 217
+#define KEY_tell 218
+#define KEY_telldir 219
+#define KEY_tie 220
+#define KEY_tied 221
+#define KEY_time 222
+#define KEY_times 223
+#define KEY_tr 224
+#define KEY_truncate 225
+#define KEY_uc 226
+#define KEY_ucfirst 227
+#define KEY_umask 228
+#define KEY_undef 229
+#define KEY_unless 230
+#define KEY_unlink 231
+#define KEY_unpack 232
+#define KEY_unshift 233
+#define KEY_untie 234
+#define KEY_until 235
+#define KEY_use 236
+#define KEY_utime 237
+#define KEY_values 238
+#define KEY_vec 239
+#define KEY_wait 240
+#define KEY_waitpid 241
+#define KEY_wantarray 242
+#define KEY_warn 243
+#define KEY_while 244
+#define KEY_write 245
+#define KEY_x 246
+#define KEY_xor 247
+#define KEY_y 248
listen
local
localtime
+lock
log
lstat
lt
OP_EGRENT, /* 341 */
OP_GETLOGIN, /* 342 */
OP_SYSCALL, /* 343 */
+ OP_LOCK, /* 344 */
OP_max
} opcode;
-#define MAXO 344
+#define MAXO 345
#ifndef DOINIT
EXT char *op_name[];
"egrent",
"getlogin",
"syscall",
+ "lock",
};
#endif
"endgrent",
"getlogin",
"syscall",
+ "lock",
};
#endif
OP * pp_egrent _((ARGSproto));
OP * pp_getlogin _((ARGSproto));
OP * pp_syscall _((ARGSproto));
+OP * pp_lock _((ARGSproto));
#ifndef DOINIT
EXT OP * (*ppaddr[])();
pp_egrent,
pp_getlogin,
pp_syscall,
+ pp_lock,
};
#endif
ck_null, /* egrent */
ck_null, /* getlogin */
ck_fun, /* syscall */
+ ck_null, /* lock */
};
#endif
0x00000014, /* egrent */
0x0000000c, /* getlogin */
0x0000211d, /* syscall */
+ 0x00000114, /* lock */
};
#endif
# Miscellaneous.
syscall syscall ck_fun imst S L
+
+# For multi-threading
+lock lock ck_null is S
static void doencodes _((SV* sv, char* s, I32 len));
static SV* refto _((SV* sv));
static U32 seed _((void));
+#ifdef USE_THREADS
+static void unlock_condpair _((void*));
+#endif /* USE_THREADS */
static bool srand_called = FALSE;
RETPUSHUNDEF;
}
+#ifdef USE_THREADS
+static void
+unlock_condpair(svv)
+void *svv;
+{
+ dTHR;
+ MAGIC *mg = mg_find((SV*)svv, 'm');
+
+ if (!mg)
+ croak("panic: unlock_condpair unlocking non-mutex");
+ MUTEX_LOCK(MgMUTEXP(mg));
+ if (MgOWNER(mg) != thr)
+ croak("panic: unlock_condpair unlocking mutex that we don't own");
+ MgOWNER(mg) = 0;
+ COND_SIGNAL(MgOWNERCONDP(mg));
+ MUTEX_UNLOCK(MgMUTEXP(mg));
+}
+#endif /* USE_THREADS */
+
+PP(pp_lock)
+{
+ dSP;
+#ifdef USE_THREADS
+ dTOPss;
+ MAGIC *mg;
+
+ if (SvROK(sv))
+ sv = SvRV(sv);
+
+ mg = condpair_magic(sv);
+ MUTEX_LOCK(MgMUTEXP(mg));
+ if (MgOWNER(mg) == thr)
+ MUTEX_UNLOCK(MgMUTEXP(mg));
+ else {
+ while (MgOWNER(mg))
+ COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg));
+ MgOWNER(mg) = thr;
+ MUTEX_UNLOCK(MgMUTEXP(mg));
+ save_destructor(unlock_condpair, sv);
+ }
+#endif /* USE_THREADS */
+ PUSHs(&sv_yes);
+ RETURN;
+}
return sv_cmp_locale(*(SV * const *)a, *(SV * const *)b);
}
-#ifdef USE_THREADS
-static void
-unlock_condpair(svv)
-void *svv;
-{
- dTHR;
- MAGIC *mg = mg_find((SV*)svv, 'm');
-
- if (!mg)
- croak("panic: unlock_condpair unlocking non-mutex");
- MUTEX_LOCK(MgMUTEXP(mg));
- if (MgOWNER(mg) != thr)
- croak("panic: unlock_condpair unlocking mutex that we don't own");
- MgOWNER(mg) = 0;
- COND_SIGNAL(MgOWNERCONDP(mg));
- MUTEX_UNLOCK(MgMUTEXP(mg));
-}
-#endif /* USE_THREADS */
-
PP(pp_reset)
{
dSP;
-#ifdef USE_THREADS
- dTOPss;
- MAGIC *mg;
-
- if (MAXARG < 1)
- croak("reset requires mutex argument with USE_THREADS");
- if (SvROK(sv)) {
- /*
- * Kludge to allow lock of real objects without requiring
- * to pass in every type of argument by explicit reference.
- */
- sv = SvRV(sv);
- }
- mg = condpair_magic(sv);
- MUTEX_LOCK(MgMUTEXP(mg));
- if (MgOWNER(mg) == thr)
- MUTEX_UNLOCK(MgMUTEXP(mg));
- else {
- while (MgOWNER(mg))
- COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg));
- MgOWNER(mg) = thr;
- MUTEX_UNLOCK(MgMUTEXP(mg));
- save_destructor(unlock_condpair, sv);
- }
- RETURN;
-#else
char *tmps;
if (MAXARG < 1)
sv_reset(tmps, curcop->cop_stash);
PUSHs(&sv_yes);
RETURN;
-#endif /* USE_THREADS */
}
PP(pp_lineseq)
case KEY_listen:
LOP(OP_LISTEN,XTERM);
+ case KEY_lock:
+ UNI(OP_LOCK);
+
case KEY_lstat:
UNI(OP_LSTAT);
case 4:
if (strEQ(d,"last")) return KEY_last;
if (strEQ(d,"link")) return -KEY_link;
+ if (strEQ(d,"lock")) return -KEY_lock;
break;
case 5:
if (strEQ(d,"local")) return KEY_local;