Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
107cfed
Wrong Printf version requirement printing
afxgroup Jan 28, 2025
5b66b34
Merge branch 'development' of github.com:AmigaLabs/clib4 into develop…
afxgroup Apr 15, 2025
c7de956
Merge branch 'development' of github.com:AmigaLabs/clib4 into develop…
afxgroup Jun 11, 2025
183789d
Merge branch 'development' of github.com:AmigaLabs/clib4 into develop…
afxgroup Jun 18, 2025
8eb5426
Small profile fixes
afxgroup Jun 20, 2025
275ac3f
Merge branch 'development' of github.com:AmigaLabs/clib4 into develop…
afxgroup Jun 22, 2025
e4eee2e
Merge branch 'development' of github.com:AmigaLabs/clib4 into develop…
afxgroup Jun 28, 2025
838afc6
Fixed crash when debug is enabled
afxgroup Jun 29, 2025
065856b
Merge branch 'development' of github.com:AmigaLabs/clib4 into mutexes
afxgroup Jun 29, 2025
4d264b8
Semaphores are replaced by Mutexes when possible
afxgroup Jun 29, 2025
27e537e
Reworked ctype implementation using newlib one
afxgroup Jul 1, 2025
100e8f2
don't call check_abort in stdio functions that are calling it already…
afxgroup Jul 2, 2025
427448d
ctype functions was using wrong _P define (while ctype inline #define…
afxgroup Jul 2, 2025
f470c36
Merge branch 'development' of github.com:AmigaLabs/clib4 into ctype
afxgroup Jul 3, 2025
d737595
More optimizations on I/O functions that avoid useless check abort calls
afxgroup Jul 5, 2025
74744ce
More optimizations to I/O operations. Now stdout and stderr are fully…
afxgroup Jul 5, 2025
9a83362
Some more optimizations
afxgroup Jul 18, 2025
0909757
more read fixes
afxgroup Jul 27, 2025
91fb653
Merge branch 'development' of github.com:AmigaLabs/clib4 into ctype
afxgroup Jul 27, 2025
7c565c2
Fixed an error on pthreds was causing DSI in some occasions. Small fixes
afxgroup Jul 29, 2025
376d5eb
Merge branch 'development' of github.com:AmigaLabs/clib4 into ctype
afxgroup Jul 29, 2025
9ff4fe2
Merge branch 'development' of github.com:AmigaLabs/clib4 into ctype
afxgroup Aug 1, 2025
43a9caf
Fixed a problem cased by wrong Input/Output/Error streams created bef…
afxgroup Aug 5, 2025
5907b1b
Merge branch 'development' of github.com:AmigaLabs/clib4 into ctype
afxgroup Aug 6, 2025
33d5b28
Merge branch 'development' of github.com:AmigaLabs/clib4 into ctype
afxgroup Aug 7, 2025
a3468f7
Speedup lookup_name function was loading and parsing resolv conf file…
afxgroup Aug 12, 2025
d53f21a
Fixed fopen was slowing down due a mistake on file buffer.
afxgroup Aug 14, 2025
e1d0855
Replaced Semaphores with Mutexes in pthread library
afxgroup Aug 16, 2025
0fe3f13
Merge branch 'development' of github.com:AmigaLabs/clib4 into ctype
afxgroup Aug 16, 2025
60c1823
Clib4 2.0.0 (#295)
afxgroup Aug 16, 2025
94a9343
Merge branch 'master' of github.com:AmigaLabs/clib4 into ctype
afxgroup Aug 16, 2025
f8e3fda
Changing the way we push new versions to the DEB server
walkero-gr Aug 16, 2025
f037545
Merge pull request #296 from AmigaLabs/update-scp-method
walkero-gr Aug 16, 2025
9f79e29
Moved the scp code in the compile
walkero-gr Aug 16, 2025
ecd2005
Merge pull request #297 from AmigaLabs/update-scp-method
walkero-gr Aug 16, 2025
4690b40
Pass the secrets as env variables
walkero-gr Aug 16, 2025
b23a931
Temporarily disabled some actions
walkero-gr Aug 16, 2025
62c70c2
Merge pull request #298 from AmigaLabs/update-scp-method
walkero-gr Aug 16, 2025
30e2a10
Added the at the start of the workflow
walkero-gr Aug 16, 2025
a967952
Set secrets as inherited
walkero-gr Aug 16, 2025
0d86be1
Merge pull request #299 from AmigaLabs/update-scp-method
walkero-gr Aug 16, 2025
7d9225b
Fixed the private key secret
walkero-gr Aug 16, 2025
9a3d6c5
Merge pull request #300 from AmigaLabs/update-scp-method
walkero-gr Aug 16, 2025
2c01c91
Finalising the new scp process
walkero-gr Aug 16, 2025
9e6bff1
Merge pull request #302 from AmigaLabs/update-scp-method
walkero-gr Aug 16, 2025
30cff75
Removed funding
walkero-gr Aug 16, 2025
ab40f98
Merge pull request #303 from AmigaLabs/update-scp-method
walkero-gr Aug 16, 2025
15dff4f
Release v2.0.0 changes
walkero-gr Aug 16, 2025
7bfb5fb
Merge pull request #304 from AmigaLabs/release/v2.0.0
walkero-gr Aug 16, 2025
e769123
Merge branch 'master' of github.com:AmigaLabs/clib4 into ctype
afxgroup Aug 17, 2025
d3575dc
Fixed a DSI on mkdir caused by read only variable being written
afxgroup Aug 21, 2025
c1b9e43
Merge branch 'development' of github.com:AmigaLabs/clib4 into file_io
afxgroup Aug 21, 2025
766dec8
Fixed a DSI on fstat() when used on a directory
afxgroup Aug 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions library/fcntl/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
int
open(const char *path_name, int open_flag, ... /* mode_t mode */) {
struct _clib4 *__clib4 = __CLIB4;
return __open_r(__clib4, path_name, open_flag);
va_list ap;
va_start(ap, open_flag);
return __open_r(__clib4, path_name, open_flag, va_arg(ap, int));
va_end(ap);
}

int
Expand Down Expand Up @@ -265,10 +268,12 @@ __open_r(struct _clib4 *__clib4, const char *path_name, int open_flag, ... /* mo

fd = __clib4->__fd[fd_slot_number];

if (is_directory || FLAG_IS_SET(open_flag, O_PATH))
if (is_directory || FLAG_IS_SET(open_flag, O_PATH)) {
__initialize_fd(fd, __fd_hook_entry, dir_lock, 0, fd_lock); // TODO - Create a new dir hook
else
}
else {
__initialize_fd(fd, __fd_hook_entry, handle, 0, fd_lock);
}

fd->fd_Aux = (char *) path_name;

Expand Down Expand Up @@ -384,7 +389,7 @@ __open_r(struct _clib4 *__clib4, const char *path_name, int open_flag, ... /* mo
if (lock != BZERO)
UnLock(lock);

if (dir_lock != BZERO)
if (!is_directory && dir_lock != BZERO)
UnLock(dir_lock);

__stdio_unlock(__clib4);
Expand Down
1 change: 1 addition & 0 deletions library/libc_init_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ reent_init(struct _clib4 *__clib4, const BOOL fallback) {
.isTZSet = 0,
.__IDebug = NULL,
.resolv_conf = NULL,
.__file_lock_semaphore_name = "Advisory File Locking"
};

if (!__clib4->__random_lock || !__clib4->__pipe_semaphore) {
Expand Down
5 changes: 4 additions & 1 deletion library/stdio/fclose.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ fclose(FILE *stream) {
/* Get rid of any custom file buffer allocated. */
if (file->iob_CustomBuffer != NULL) {
SHOWMSG("Delete allocated buffer");
ItemPoolFree(__clib4->_iob_pool, file->iob_CustomBuffer);
if (file->iob_isVBuffer)
FreeVec(file->iob_CustomBuffer);
else
ItemPoolFree(__clib4->_iob_pool, file->iob_CustomBuffer);
file->iob_CustomBuffer = NULL;
}

Expand Down
8 changes: 4 additions & 4 deletions library/stdio/fdhookentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,10 @@ int64_t __fd_hook_entry(struct _clib4 *__clib4, struct fd *fd, struct file_actio
// TODO - Check this on OS4 with NIL:
fam->fam_FileInfo->Type = ST_NIL;
} else {
BPTR lock_type = FLAG_IS_SET(fd->fd_Flags, FDF_IS_DIRECTORY) || FLAG_IS_SET(fd->fd_Flags, FDF_PATH_ONLY)
? EX_LockInput
: EX_FileHandleInput;
fam->fam_FileInfo = ExamineObjectTags(lock_type, file, TAG_DONE);
if (FLAG_IS_SET(fd->fd_Flags, FDF_IS_DIRECTORY) || FLAG_IS_SET(fd->fd_Flags, FDF_PATH_ONLY))
fam->fam_FileInfo = ExamineObjectTags(EX_LockInput, file, TAG_DONE);
else
fam->fam_FileInfo = ExamineObjectTags(EX_FileHandleInput, file, TAG_DONE);
if (fam->fam_FileInfo == NULL) {
LONG error;

Expand Down
1 change: 1 addition & 0 deletions library/stdio/initializeiob.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ __initialize_iob(
memset(iob, 0, sizeof(*iob));

iob->iob_CustomBuffer = custom_buffer;
iob->iob_isVBuffer = FALSE;
iob->iob_Buffer = (UBYTE *)buffer;
iob->iob_BufferSize = buffer_size;
iob->iob_Descriptor = file_descriptor;
Expand Down
12 changes: 8 additions & 4 deletions library/stdio/record_locking.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,11 @@ __handle_record_locking(struct _clib4 *__clib4, int cmd, struct flock *l, struct
_off64_t seek_position;
_off64_t current_position;
int result = ERROR;
_off64_t original_len;
_off64_t original_len = 0;
LONG error = OK;
_off64_t start = 0;
_off64_t len = 0;
_off64_t stop;
_off64_t stop = 0;

ENTER();

Expand All @@ -591,7 +591,7 @@ __handle_record_locking(struct _clib4 *__clib4, int cmd, struct flock *l, struct
/* Remember to unlock any records before closing the file. */
fd->fd_Cleanup = cleanup_locked_records;

if ((cmd == F_SETLK || cmd == F_SETLKW) && (l->l_type != F_UNLCK)) {
if ((cmd == F_SETLK || cmd == F_SETLKW) && (l->l_type == F_WRLCK || l->l_type == F_RDLCK)) {
SHOWMSG("this is a lock request");

error = create_file_lock_node(__clib4, fd, &fln);
Expand All @@ -605,7 +605,11 @@ __handle_record_locking(struct _clib4 *__clib4, int cmd, struct flock *l, struct
SHOWMSG("could not create region node");
goto out;
}
} else {
}
else if (l->l_type == F_UNLCK) {
SHOWMSG("this is an unlock request");
}
else {
SHOWMSG("this is not a lock request");
goto out;
}
Expand Down
17 changes: 13 additions & 4 deletions library/stdio/setvbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ setvbuf(FILE *stream, char *buf, int bufmode, size_t size) {
allocate some memory for it. */
if (size > 0 && buf == NULL) {
/* Allocate a little more memory than necessary. */
new_buffer = ItemPoolAlloc(__clib4->_iob_pool);
new_buffer = AllocVecTags(size, AVT_Type, MEMF_SHARED, AVT_ClearWithValue, 0, TAG_DONE);
if (new_buffer == NULL) {
__set_errno_r(__clib4, ENOBUFS);
goto out;
}
file->iob_isVBuffer = TRUE;
}
}

Expand All @@ -98,7 +99,11 @@ setvbuf(FILE *stream, char *buf, int bufmode, size_t size) {
/* Get rid of any buffer specially allocated for this stream. */
if (file->iob_CustomBuffer != NULL) {
SHOWMSG("Delete allocated buffer");
ItemPoolFree(__clib4->_iob_pool, file->iob_CustomBuffer);
if (file->iob_isVBuffer)
FreeVec(file->iob_CustomBuffer);
else
ItemPoolFree(__clib4->_iob_pool, file->iob_CustomBuffer);

file->iob_CustomBuffer = NULL;
}

Expand Down Expand Up @@ -137,8 +142,12 @@ setvbuf(FILE *stream, char *buf, int bufmode, size_t size) {

__funlockfile_r(__clib4, stream);

if (new_buffer != NULL)
ItemPoolFree(__clib4->_iob_pool, new_buffer);
if (new_buffer != NULL) {
if (file->iob_isVBuffer)
FreeVec(file->iob_CustomBuffer);
else
ItemPoolFree(__clib4->_iob_pool, file->iob_CustomBuffer);
}

RETURN(result);
return result;
Expand Down
1 change: 1 addition & 0 deletions library/stdio/stdio_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ typedef struct iob {
UBYTE iob_SingleByte; /* Fall-back buffer for 'unbuffered' files */
APTR iob_Lock; /* For thread locking */
struct Task * iob_TaskLock; /* Task who owns lock */
BOOL iob_isVBuffer; /* TRUE if iob_CustomBuffer is set from setvbuf */
} __iob64;


Expand Down
2 changes: 1 addition & 1 deletion library/wmem/wmem_allocator_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ wmem_block_split_used_chunk(wmem_block_allocator_t *allocator,
bool last;

#ifdef MEMORY_DEBUG
D(("[split_used :] chunk : 0x%lx\n", chunk));
D(("[split_used :] data : 0x%lx\n", data));
#endif

aligned_size = size + ((uintptr_t)data - (uintptr_t)WMEM_DATA_TO_CHUNK(data));
Expand Down
45 changes: 45 additions & 0 deletions test_programs/io/open_dir.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>

int main(void) {
const char *dir_path = "T:"; // Use the current directory
int fd;
struct stat sb;

// Open the directory
printf("Attempting to open directory: '%s'\n", dir_path);
fd = open(dir_path, O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
}
printf("Directory opened successfully with file descriptor: %d\n", fd);

// Get file status using fstat() on the file descriptor
if (fstat(fd, &sb) == -1) {
perror("fstat");
close(fd);
exit(EXIT_FAILURE);
}
printf("fstat() called successfully on the file descriptor.\n");

// Print some information from the stat buffer
printf("File type: ");
switch (sb.st_mode & S_IFMT) {
case S_IFDIR: printf("directory\n"); break;
case S_IFREG: printf("regular file\n"); break;
case S_IFLNK: printf("symbolic link\n"); break;
default: printf("unknown?\n"); break;
}
printf("Number of hard links: %ld\n", (long) sb.st_nlink);
printf("File size: %lld bytes\n", (long long) sb.st_size);

// Close the file descriptor
close(fd);
printf("File descriptor closed.\n");

return 0;
}
28 changes: 28 additions & 0 deletions test_programs/io/setvbuf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>

#define BUF_SIZE 1024

int main(void) {
char buffer[BUF_SIZE];

printf("Initial output.\n");
printf("This line is in the default buffer, but will be flushed at the end.\n");

// Use setvbuf to assign a new, fully buffered buffer to stdout.
if (setvbuf(stdout, buffer, _IOFBF, BUF_SIZE) != 0) {
perror("setvbuf failed");
return 1;
}

printf("This text is now being written to the new custom buffer.\n");
printf("You will not see this until the buffer is full, or the program ends.\n");

// We can prove the custom buffer is used by forcing a flush.
// Uncomment the next line to see the output immediately.
fflush(stdout);

printf("Final line before exit.\n");

return 0;
}