diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-07-19 19:00:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:29:44 -0500 |
commit | d99d06d954321331f8558da8604e1fd4dd956d13 (patch) | |
tree | 052e242ee7d61e658d6ec78b216587143f06565d /source4 | |
parent | 8f16aa6c179a6157a4fbece3b30ef6ebfb3f5562 (diff) | |
download | samba-d99d06d954321331f8558da8604e1fd4dd956d13.tar.gz samba-d99d06d954321331f8558da8604e1fd4dd956d13.tar.bz2 samba-d99d06d954321331f8558da8604e1fd4dd956d13.zip |
r8612: Parse::Pidl::NDR:
Values that are deferred but don't contain deferred data don't
need NDR_BUFFERS
Parse::Pidl::Samba::NDR::Parser:
Only use manually written array access functions when the array
functions are faster then the autogenerated ones. Makes ndr_basic.c
a bit shorter.
(This used to be commit cad40815dcfb7cdcab13bd0cd204ef8711605ef3)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/Parse/Pidl/NDR.pm | 5 | ||||
-rw-r--r-- | source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm | 15 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 192 |
3 files changed, 11 insertions, 201 deletions
diff --git a/source4/build/pidl/Parse/Pidl/NDR.pm b/source4/build/pidl/Parse/Pidl/NDR.pm index 0c2b00539d..33d7839a3a 100644 --- a/source4/build/pidl/Parse/Pidl/NDR.pm +++ b/source4/build/pidl/Parse/Pidl/NDR.pm @@ -9,7 +9,7 @@ package Parse::Pidl::NDR; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(GetPrevLevel GetNextLevel); +@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred); use strict; use Parse::Pidl::Typelist qw(hasType getType); @@ -195,7 +195,6 @@ sub GetElementLevelTable($) nonfatal($e, "string() attribute on non-array element"); } - push (@$order, { TYPE => "DATA", DATA_TYPE => $e->{TYPE}, @@ -216,13 +215,13 @@ sub can_contain_deferred { my $e = shift; - return 1 if ($e->{POINTERS}); return 0 if (Parse::Pidl::Typelist::is_scalar($e->{TYPE})); return 1 unless (hasType($e->{TYPE})); # assume the worst my $type = getType($e->{TYPE}); foreach my $x (@{$type->{DATA}->{ELEMENTS}}) { + return 1 if ($x->{POINTERS}); return 1 if (can_contain_deferred ($x)); } diff --git a/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm b/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm index c04182ee14..c720ad6925 100644 --- a/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm +++ b/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm @@ -10,7 +10,7 @@ package Parse::Pidl::Samba::NDR::Parser; use strict; use Parse::Pidl::Typelist qw(hasType getType); use Parse::Pidl::Util qw(has_property ParseExpr); -use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel); +use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred); # list of known types my %typefamily; @@ -55,7 +55,10 @@ sub has_fast_array($$) return 0 unless ($nl->{TYPE} eq "DATA"); return 0 unless (hasType($nl->{DATA_TYPE})); - return Parse::Pidl::Typelist::is_scalar($nl->{DATA_TYPE}); + my $t = getType($nl->{DATA_TYPE}); + + # Only uint8 and string have fast array functions at the moment + return ($t->{NAME} eq "uint8") or ($t->{NAME} eq "string"); } sub get_pointer_to($) @@ -567,7 +570,7 @@ sub ParseElementPushLevel pidl "}"; } - if ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $l)) { + if ($deferred and ContainsDeferred($e, $l)) { pidl "for ($counter = 0; $counter < $length; $counter++) {"; indent; ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1); @@ -590,7 +593,7 @@ sub ParseElementPush($$$$$$) $var_name = append_prefix($e, $var_name); - return unless $primitives or ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $e->{LEVELS}[0])); + return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0])); start_flags($e); @@ -881,7 +884,7 @@ sub ParseElementPullLevel } } - if ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $l)) { + if ($deferred and ContainsDeferred($e, $l)) { pidl "for ($counter = 0; $counter < $length; $counter++) {"; indent; ParseElementPullLevel($e,GetNextLevel($e,$l), $ndr, $var_name, $env, 0, 1); @@ -903,7 +906,7 @@ sub ParseElementPull($$$$$$) $var_name = append_prefix($e, $var_name); - return unless $primitives or ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $e->{LEVELS}[0])); + return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0])); start_flags($e); diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5046b860a3..efff2dbc5f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -263,66 +263,6 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data } /* - pull an array of uint16 -*/ -NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *data, uint32_t n) -{ - uint32_t i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &data[i])); - } - return NT_STATUS_OK; -} - -/* - pull a const array of uint32_t -*/ -NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *data, uint32_t n) -{ - uint32_t i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &data[i])); - } - return NT_STATUS_OK; -} - -/* - pull a const array of hyper -*/ -NTSTATUS ndr_pull_array_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *data, uint32_t n) -{ - uint32_t i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &data[i])); - } - return NT_STATUS_OK; -} - -/* - pull a const array of WERROR -*/ -NTSTATUS ndr_pull_array_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *data, uint32_t n) -{ - uint32_t i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &data[i])); - } - return NT_STATUS_OK; -} - -/* push a int8_t */ NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) @@ -481,66 +421,6 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t } /* - push an array of uint16 -*/ -NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16_t *data, uint32_t n) -{ - int i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, data[i])); - } - return NT_STATUS_OK; -} - -/* - push an array of uint32_t -*/ -NTSTATUS ndr_push_array_uint32(struct ndr_push *ndr, int ndr_flags, const uint32_t *data, uint32_t n) -{ - int i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, data[i])); - } - return NT_STATUS_OK; -} - -/* - push an array of hyper -*/ -NTSTATUS ndr_push_array_hyper(struct ndr_push *ndr, int ndr_flags, const uint64_t *data, uint32_t n) -{ - int i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, data[i])); - } - return NT_STATUS_OK; -} - -/* - push an array of hyper -*/ -NTSTATUS ndr_push_array_WERROR(struct ndr_push *ndr, int ndr_flags, const WERROR *data, uint32_t n) -{ - int i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;i<n;i++) { - NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, data[i])); - } - return NT_STATUS_OK; -} - -/* save the current position */ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) @@ -837,78 +717,6 @@ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level ndr->print(ndr, "UNKNOWN LEVEL %u", level); } -void ndr_print_array_WERROR(struct ndr_print *ndr, const char *name, - const WERROR *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;i<count;i++) { - char *idx=NULL; - asprintf(&idx, "[%d]", i); - if (idx) { - ndr_print_WERROR(ndr, idx, data[i]); - free(idx); - } - } - ndr->depth--; -} - -void ndr_print_array_hyper(struct ndr_print *ndr, const char *name, - const uint64_t *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;i<count;i++) { - char *idx=NULL; - asprintf(&idx, "[%d]", i); - if (idx) { - ndr_print_hyper(ndr, idx, data[i]); - free(idx); - } - } - ndr->depth--; -} - -void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, - const uint32_t *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;i<count;i++) { - char *idx=NULL; - asprintf(&idx, "[%d]", i); - if (idx) { - ndr_print_uint32(ndr, idx, data[i]); - free(idx); - } - } - ndr->depth--; -} - -void ndr_print_array_uint16(struct ndr_print *ndr, const char *name, - const uint16_t *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;i<count;i++) { - char *idx=NULL; - asprintf(&idx, "[%d]", i); - if (idx) { - ndr_print_uint16(ndr, idx, data[i]); - free(idx); - } - } - ndr->depth--; -} - void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, const uint8_t *data, uint32_t count) { |