Skip to content

sys/resource: implement getrlimit/setrlimit - #517

Open
etiaro wants to merge 1 commit into
masterfrom
etiaro/rlimits
Open

etiaro wants to merge 1 commit into
masterfrom
etiaro/rlimits

Conversation

@etiaro

@etiaro etiaro commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

TASK: RTOS-1346

Description

Implement POSIX getrlimit/setrlimit functions, declare a new syscall signature.

Motivation and Context

POSIX API compliance, Foundation API

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the stubs for getrlimit and setrlimit with actual implementations wrapping the rlimits system call, alongside header updates in include/sys/resource.h. Key feedback includes a warning that implicitly changing RUSAGE_CHILDREN to 1 via an enum breaks compatibility, a recommendation to use 0 instead of RLIMIT_SELF for the target PID, and a suggestion to define these wrappers as static inline functions in the header to optimize code size.

Comment thread include/sys/resource.h Outdated
Comment thread sys/resource.c Outdated
Comment thread sys/resource.c Outdated
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

Unit Test Results

13 287 tests   12 469 ✅  57m 18s ⏱️
   756 suites     818 💤
     1 files         0 ❌

Results for commit 1e68b90.

♻️ This comment has been updated with latest results.

@etiaro
etiaro marked this pull request as ready for review August 14, 2026 10:35
@etiaro
etiaro requested a review from a team August 14, 2026 10:35
@ziemleszcz

Copy link
Copy Markdown
Contributor

Are there any tests for these syscalls?

Comment thread include/sys/resource.h
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
extern int rlimits(limit_target_t target, int resource, struct rlimit *oldLimit, const struct rlimit *newLimit);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add extern to function declarations. Instead, remove all extern qualifiers from function declarations in this file.

Comment thread include/sys/resource.h
extern int getrusage(int who, struct rusage *usage);


static inline int getrlimit(int resource, struct rlimit *rlp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use static inline. See phoenix-rtos/phoenix-rtos-project#1722.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants