Skip to content

Conversation

@ajayrajsaini
Copy link
Contributor

This pull request adds a new header file, SysExits.h, to the LLVM project. The header includes 18 BSD exit code.

@github-actions
Copy link

github-actions bot commented Feb 6, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-libc

@llvm/pr-subscribers-llvm-support

Author: None (ajayrajsaini)

Changes

This pull request adds a new header file, SysExits.h, to the LLVM project. The header includes 18 BSD exit code.


Full diff: https://github.com/llvm/llvm-project/pull/126112.diff

1 Files Affected:

  • (added) llvm/include/llvm/Support/SysExits.h (+24)
diff --git a/llvm/include/llvm/Support/SysExits.h b/llvm/include/llvm/Support/SysExits.h
new file mode 100644
index 000000000000000..06b3ada101756e7
--- /dev/null
+++ b/llvm/include/llvm/Support/SysExits.h
@@ -0,0 +1,24 @@
+#ifndef SYSEXITS_H
+#define SYSEXITS_H
+
+// BSD Exit Codes (18 total) — These are the commonly used exit codes without POSIX dependencies
+#define EX_OK         0    // Successful termination
+#define EX_USAGE      64   // Command line usage error
+#define EX_DATAERR    65   // Data format error
+#define EX_NOINPUT    66   // Cannot open input
+#define EX_NOUSER     67   // Addressee unknown
+#define EX_NOHOST     68   // Host name unknown
+#define EX_UNAVAILABLE 69  // Service unavailable
+#define EX_SOFTWARE   70   // Internal software error
+#define EX_OSERR      71   // Operating system error
+#define EX_OSFILE     72   // System file error
+#define EX_CANTCREAT  73   // Cannot create (user) output file
+#define EX_IOERR      74   // Input/output error
+#define EX_TEMPFAIL   75   // Temporary failure, try again
+#define EX_PROTOCOL   76   // Remote protocol error
+#define EX_NOPERM     77   // Permission denied
+#define EX_CONFIG     78   // Configuration error
+#define EX_INTERNAL   80   // Internal error
+#define EX_INVALIDARG 81   // Invalid argument
+
+#endif // SYSEXITS_H

Copy link
Member

@nickdesaulniers nickdesaulniers left a comment

Choose a reason for hiding this comment

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

Ah, sorry, the intent of #124640 was to provide sysexits.h to llvm-libc, (lib/), not llvm itself.

Specifically, that build failure isn't llvm's fault, it's only when building llvm on top of the nascent llvm-libc is the deficiency in llvm-libc exposed.

@llvmbot llvmbot added the libc label Feb 8, 2025
@ajayrajsaini
Copy link
Contributor Author

Hi @nickdesaulniers please review the PR and let me know if there is any changes needed

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

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

This doesn't seem to define the header, it just adds this file in the lib/ directory? Look at how we handle the other headers in include/. Specifically you'll want to understand the hdrgen utility and the config/<os>/headers.txt files.

@nickdesaulniers
Copy link
Member

6807164 is a good reference example on what adding a new header entails.

The headers.txt files are what roots the generation of the headers into the build system.

You can for now skip additions to libc/docs/, since I don't think I properly handle in docgen what to do for BSD extensions (docgen will error IIRC if you add things that aren't std C or POSIX).

@ajayrajsaini
Copy link
Contributor Author

Hey @nickdesaulniers , @jhuber6 i had made the requested changes will you review it once

Comment on lines 20 to 21
#define EX_INTERNAL 80 // Internal error
#define EX_INVALIDARG 81 // Invalid argument
Copy link
Member

Choose a reason for hiding this comment

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

Where did you find EX_INTERNAL and EX_INVALIDARG? glibc, bionic, and musl only have up to EX_CONFIG.

Copy link
Member

Choose a reason for hiding this comment

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

Question still stands; if these are from a BSD, it would be good to know which BSD adds these two new symbolic constants.

…dards, removed EX_INTERNAL and EX_INVALIDARG
@ajayrajsaini
Copy link
Contributor Author

Hey @nickdesaulniers and @jhuber6 ,
Thank you so much for your guidance on my first contribution to LLVM. I really enjoyed working on it and learned a lot during the process. I would love to work on more issues if any are available and promise to avoid the mistakes I made this time. Please assign me any tasks where I can contribute further. Thanks again!"

@lntue
Copy link
Contributor

lntue commented Feb 28, 2025

@ajayrajsaini Do you mind resolving the conflict so that we can merge this PR? Thanks!

@github-actions
Copy link

github-actions bot commented Mar 3, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

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

LGTM, @lntue do you want to merge it or should I?

@lntue
Copy link
Contributor

lntue commented Mar 6, 2025

LGTM, @lntue do you want to merge it or should I?

You can go ahead, I'm away from the computer right now.

@michaelrj-google michaelrj-google merged commit 9a65dc9 into llvm:main Mar 7, 2025
16 checks passed
@github-actions
Copy link

github-actions bot commented Mar 7, 2025

@ajayrajsaini Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants