Lines Matching +full:lock +full:- +full:less

4  * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2018-2024 Gavin D. Howard and contributors.
78 buf[i] = buf2[len - i - 1];
94 sig_atomic_t lock;
96 BC_SIG_TRYLOCK(lock);
98 // While the number of bytes written is less than intended...
102 ssize_t written = write(fd, buf + bytes, n - bytes);
105 if (BC_ERR(written == -1))
107 BC_SIG_TRYUNLOCK(lock);
115 BC_SIG_TRYUNLOCK(lock);
132 if (fflush(f->f) == EOF) s = BC_STATUS_ERROR_FATAL;
138 if (f->len)
147 if (f->buf[f->len - 1] != '\n' &&
154 for (i = f->len - 2; i < f->len && f->buf[i] != '\n'; --i)
162 bc_vec_string(&vm->history.extras, f->len - i, f->buf + i);
167 bc_vec_popAll(&vm->history.extras);
173 s = bc_file_output(f->fd, f->buf, f->len);
174 f->len = 0;
187 sig_atomic_t lock;
189 BC_SIG_TRYLOCK(lock);
199 vm->status = (sig_atomic_t) s;
200 BC_SIG_TRYUNLOCK(lock);
203 // Make sure to handle non-fatal I/O properly.
204 else if (!f->errors_fatal)
212 BC_SIG_TRYUNLOCK(lock);
220 sig_atomic_t lock;
222 BC_SIG_TRYLOCK(lock);
225 if (n > f->cap - f->len)
228 assert(!f->len);
233 if (BC_UNLIKELY(n > f->cap - f->len))
235 BcStatus s = bc_file_output(f->fd, buf, n);
242 vm->status = (sig_atomic_t) s;
243 BC_SIG_TRYUNLOCK(lock);
246 // Make sure to handle non-fatal I/O properly.
247 else if (!f->errors_fatal)
258 memcpy(f->buf + f->len, buf, n);
259 f->len += n;
262 BC_SIG_TRYUNLOCK(lock);
271 sig_atomic_t lock;
273 BC_SIG_TRYLOCK(lock);
279 BC_SIG_TRYUNLOCK(lock);
294 #pragma clang diagnostic ignored "-Wformat-nonliteral"
296 r = vfprintf(f->f, fmt, args);
298 #pragma clang diagnostic warning "-Wformat-nonliteral"
304 // Make sure to handle non-fatal I/O properly.
305 if (!f->errors_fatal)
337 size_t len = (size_t) (percent - ptr);
366 bc_file_putchar(f, bc_flush_none, '-');
367 d = -d;
385 // code, more or less.
428 sig_atomic_t lock;
430 BC_SIG_TRYLOCK(lock);
434 if (BC_ERR(fputc(c, f->f) == EOF))
437 if (f->f == stderr) exit(BC_STATUS_ERROR_FATAL);
444 if (f->len == f->cap) bc_file_flush(f, type);
446 assert(f->len < f->cap);
448 f->buf[f->len] = (char) c;
449 f->len += 1;
453 BC_SIG_TRYUNLOCK(lock);
462 f->f = file;
463 f->errors_fatal = errors_fatal;
473 f->fd = fd;
474 f->buf = buf;
475 f->len = 0;
476 f->cap = cap;
477 f->errors_fatal = errors_fatal;