[gst-devel] Re: making GstBuffer opaque

vishnu at pobox.com vishnu at pobox.com
Tue Sep 25 13:28:01 CEST 2001


On Tue, Sep 25, 2001 at 12:51:35PM -0700, vishnu at pobox.com wrote:
> Good idea.  i'll write some sample code and show asm output.  i've never
> had a chance to learn x86 asm, so this will be fun.

The attached demonstration proves the effectiveness of inline functions.
A quick look at the assembler output will reveal exactly the same insns
generated for both setup1 (macros) and setup2 (inline functions).

The advantages of functions include:

+ Easier to annotated with debug assertions.

+ GstBuffer can be opaque.  We can protect the integrity of the buffer
with pre & post assertions.

+ Functions are less vulnerable to careless coding mistakes (order
of evaluation, parens, scoping, etc).

+ No optimized performance penalty.

Conclusion:  Since the GstBuffer is so important in Gstreamer, it
should be lavished with the highest levels of defensive programming.

Proposal: i can try converting the current code to a new opaque
buffer API with a perl script?

Comments?

-- 
Victory to the Divine Mother!!
  http://sahajayoga.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inline-test.c
Type: text/x-csrc
Size: 672 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20010925/9c7bb517/attachment.c>
-------------- next part --------------
	.file	"inline-test.c"
# GNU C version 3.0.1 20010811 (Debian prerelease) (i386-linux)
#	compiled by GNU C version 3.0.1 20010811 (Debian prerelease).
# options passed:  -lang-c -D__GNUC__=3 -D__GNUC_MINOR__=0
# -D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__
# -D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__
# -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__
# -D__tune_i386__ -O -finline -fverbose-asm
# options enabled:  -fdefer-pop -fthread-jumps -fpeephole -ffunction-cse
# -finline -fkeep-static-consts -fpcc-struct-return -fsched-interblock
# -fsched-spec -fbranch-count-reg -fcommon -fverbose-asm -fgnu-linker
# -fargument-alias -fident -fguess-branch-probability -fmath-errno -m80387
# -mhard-float -mno-soft-float -mieee-fp -mfp-ret-in-387

	.section	.rodata
.LC0:
	.string	"abc"
	.data
	.align 4
	.type	abc, at object
	.size	abc,4
abc:
	.long	.LC0
	.text
	.align 4
.globl setup1
	.type	setup1, at function
setup1:
	pushl	%ebp
	movl	%esp, %ebp
	movl	abc, %edx
	movl	8(%ebp), %eax
	movl	%edx, (%eax)
	cmpb	$97, (%edx)
	setne	%al
	movzbl	%al, %eax
	popl	%ebp
	ret
.Lfe1:
	.size	setup1,.Lfe1-setup1
	.align 4
.globl setup2
	.type	setup2, at function
setup2:
	pushl	%ebp
	movl	%esp, %ebp
	movl	abc, %edx
	movl	8(%ebp), %eax
	movl	%edx, (%eax)
	cmpb	$97, (%edx)
	setne	%al
	movzbl	%al, %eax
	popl	%ebp
	ret
.Lfe2:
	.size	setup2,.Lfe2-setup2
	.align 4
.globl main
	.type	main, at function
main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$24, %esp
	andl	$-16, %esp
	subl	$12, %esp
	leal	-8(%ebp), %eax
	pushl	%eax
	call	setup1
	leal	-16(%ebp), %eax
	movl	%eax, (%esp)
	call	setup2
	movl	$0, %eax
	leave
	ret
.Lfe3:
	.size	main,.Lfe3-main
	.ident	"GCC: (GNU) 3.0.1 20010811 (Debian prerelease)"


More information about the gstreamer-devel mailing list