Skip to content
This repository
Browse code

Add Process constants to platform.conf generation

  • Loading branch information...
commit f81f44b331efd29212ad46cac32415cadbd9f964 1 parent 0ad02b5
Wilson Bilkovich wilson authored

Showing 2 changed files with 34 additions and 2 deletions. Show diff stats Hide diff stats

  1. +32 1 Rakefile
  2. +2 1  rakelib/const_generator.rb
33 Rakefile
@@ -629,15 +629,41 @@ file 'runtime/platform.conf' => 'Rakefile' do |t|
629 629 SO_LINGER
630 630 SOL_SOCKET
631 631 }
  632 +
  633 + process_constants = %w{
  634 + WNOHANG
  635 + WUNTRACED
  636 + PRIO_PROCESS
  637 + PRIO_PGRP
  638 + PRIO_USER
  639 + RLIMIT_CPU
  640 + RLIMIT_FSIZE
  641 + RLIMIT_DATA
  642 + RLIMIT_STACK
  643 + RLIMIT_CORE
  644 + RLIMIT_RSS
  645 + RLIMIT_NPROC
  646 + RLIMIT_NOFILE
  647 + RLIMIT_MEMLOCK
  648 + RLIMIT_AS
  649 + }
  650 + long_process_constants = %w{
  651 + RLIM_INFINITY
  652 + RLIM_SAVED_MAX
  653 + RLIM_SAVED_CUR
  654 + }
632 655
633 656 cg = ConstGenerator.new
634 657 cg.include "stdio.h"
635 658 cg.include "fcntl.h"
636 659 cg.include "sys/socket.h"
637 660 cg.include "sys/stat.h"
  661 + cg.include "sys/resource.h"
638 662 file_constants.each { |c| cg.const c }
639 663 io_constants.each { |c| cg.const c }
640 664 socket_constants.each { |c| cg.const c }
  665 + process_constants.each { |c| cg.const c }
  666 + long_process_constants.each { |c| cg.const(c, "%llu") }
641 667 cg.calculate
642 668
643 669 puts "Generating #{t.name}..."
@@ -650,7 +676,7 @@ file 'runtime/platform.conf' => 'Rakefile' do |t|
650 676 f.puts "rbx.platform.file.#{name} = #{const.converted_value}"
651 677 end
652 678
653   - io_constants.each do | name |
  679 + io_constants.each do |name|
654 680 const = cg.constants[name]
655 681 f.puts "rbx.platform.io.#{name} = #{const.converted_value}"
656 682 end
@@ -659,6 +685,11 @@ file 'runtime/platform.conf' => 'Rakefile' do |t|
659 685 const = cg.constants[name]
660 686 f.puts "rbx.platform.socket.#{name} = #{const.converted_value}" unless const.converted_value.nil?
661 687 end
  688 +
  689 + (process_constants + long_process_constants).each do |name|
  690 + const = cg.constants[name]
  691 + f.puts "rbx.platform.process.#{name} = #{const.converted_value}" unless const.converted_value.nil?
  692 + end
662 693 end
663 694
664 695 end
3  rakelib/const_generator.rb
@@ -4,12 +4,13 @@ class ConstGenerator
4 4 class Constant
5 5 attr_reader :name
6 6 attr_reader :format
7   - attr :value, true
  7 + attr_accessor :value
8 8
9 9 def initialize(name, format, converter=nil)
10 10 @name = name
11 11 @format = format
12 12 @converter = converter
  13 + @value = nil
13 14 end
14 15
15 16 def converted_value

0 comments on commit f81f44b

Please sign in to comment.
Something went wrong with that request. Please try again.